<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Maxim Lanin on Medium]]></title>
        <description><![CDATA[Stories by Maxim Lanin on Medium]]></description>
        <link>https://medium.com/@mlanin?source=rss-74a578e1cd21------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*6ndzu9TdcUgcUhuRqDsv4A.jpeg</url>
            <title>Stories by Maxim Lanin on Medium</title>
            <link>https://medium.com/@mlanin?source=rss-74a578e1cd21------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 14:52:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mlanin/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Sheldon: a team routine automation bot]]></title>
            <link>https://medium.com/avitotech/sheldon-a-team-routine-automation-bot-95654f33711d?source=rss-74a578e1cd21------2</link>
            <guid isPermaLink="false">https://medium.com/p/95654f33711d</guid>
            <category><![CDATA[slack]]></category>
            <category><![CDATA[slackbot]]></category>
            <category><![CDATA[it-management]]></category>
            <dc:creator><![CDATA[Maxim Lanin]]></dc:creator>
            <pubDate>Tue, 22 Mar 2022 08:41:10 GMT</pubDate>
            <atom:updated>2022-10-19T07:35:31.426Z</atom:updated>
            <content:encoded><![CDATA[<p>Before the Сovid-19, when we all worked from the office, life was simple and sweet. Everyone was physically available, sitting behind the next office desk, we could always have a quick chat to check out the progress of something or give a reminder. Team activities were offline, it was easy to get together at the blackboard or gather in a meeting room. The team TV played sprint statistics, product metrics, OKR results.</p><p>When the pandemic hit, we switched to full-time remote work, and life became different. It became more challenging. And not only for the manager, who had to restructure all their interaction with the team, but also for the team members. Multiple previously unknown routines emerged:</p><p>● Constantly monitoring the progress on different boards.</p><p>● Reminding about stand-ups, tasks and PRs.</p><p>● Bringing the team together on Zoom for meetings.</p><p>Processes and work in general began to lose transparency. It became clear that something had to be done about it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*r7sElNE1SEnLVOMOQmaJPg.png" /></figure><h3>We need more bots</h3><p>With the advent of remote work, Slack became virtually the only meeting place in addition to Zoom. We came up with the idea to write a bot that will regularly collect various statistics and upload these to the team chat.</p><p>No sooner said than done. Over the weekend, a simple bot was written, proudly named Sheldon after the Big Bang Theory character and featuring a corresponding avatar.</p><h3>Daily status</h3><p>At that time, Sheldon could only send a daily notification to the chat with a list showing the following:</p><p>● what tasks are stuck;</p><p>● what PRs are currently open and for what tasks;</p><p>● what critical bugs were found in the backlog — we have a procedure for fixing these.</p><p>Another nice thing was that in the notifications sent out every morning, the author or the one who was expected to pay attention was tagged. So the right people received notifications, and I got rid of the routine need to send out reminders.</p><p>Later, we added to Sheldon’s messages information about those who were going on vacation in the coming days and from what date, or those who were away on vacations and when they were expected to be back. At that point, a chat post looked like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rj7iJpuW2eYl9YZLiJxqxA.png" /></figure><p>Sheldon gets the information from Jira, Stash, and our internal portal.</p><h3>Weekly report</h3><p>The experiment was a success and we began to develop Sheldon. The next step was to send once per iteration an update on the general progress to the goals and task statistics. To do this, we had to train Sheldon to build a progress bar and charts.</p><p><strong>OKR progress. </strong>Unfortunately, Slack is unable to display rich graphics. We needed a solution to display the progress on OKRs. The idea was adopted <a href="https://github.com/sfreiberg/progress">from here</a> — display the progress bar as 10 ⬜ and 🟦 characters, where the former represents the progress bar itself, and the latter one — the actual progress.</p><p>Thus, if we have an OKR epic with 100 tasks and 20 of those are completed, we have the following sequence — 🟦 🟦 ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ ⬜ (20/100). The source code adapted to our use case <a href="https://gist.github.com/mlanin/fab7a5610f0d2ce481688da1af134dab">is available here</a>.</p><p>Knowing which of the epics are responsible for OKR, one can easily find out and display progress as a percentage completed. We know this is not how goal progress is calculated in the real world, but that was the only automated option that could be implemented at the time.</p><p><strong>Task statistics. </strong>Looking constantly at a cumulative chart, trying to calculate statistics, is a boring thing. Besides, we wanted to give access to such data to the entire team. Therefore, we decided to add graphs for new/completed tasks and bugs to the bot message.</p><p>This was a greater challenge — that was a graphic asset, and the only more or less working option to attach a picture to a bot message was adding a link to a file available via http. At that time, we didn’t have a working solution for adding a picture to a persistent storage, and we needed a workaround.</p><p>As a result, an <em>http</em> handler was developed that generated a chart in png based on an array of data points received via a get request. The link itself was generated at the time of sending the message after collecting the data points from the statistics. Thus, we got rid of the storage and were able to build all kinds of charts in the runtime. The only limitation is the number of data points we could display, because get is limited to 2048 characters. Source code <a href="https://github.com/mlanin/charts-by-url">is available here.</a></p><p>The result was a message that came every Monday:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*05xcW-UNtmihGbRrnuYBTw.png" /></figure><h3>More automation</h3><p>Simply showing the status and sending reminders about stuck tasks is good, but what if we add a button to close those? No sooner said than done. Sheldon learned how to close PRs with all tests passed and approval granted, as well as tasks in which all PRs were merged.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_jXBym8vVRvvnhPFYn2UNQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2CHJ7YeZYVKRPXhXYAaAVg.png" /></figure><p>Gradually, Sheldon began spilling out. It was added to the team’s general product support chat to systematize requests. The bot learned how to change team members on duty and invite everyone interested to our demos.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yu-8A8cYiZ0tGt1syeKODw.png" /></figure><p>Sheldon can much more that that:</p><ol><li>It automates the on-duty process. It assigns a team member on duty, reminds to answer a question in the channel, and reminds you when you are on duty.</li><li>It reminds you to close any open cases before you take vacations.</li><li>It reminds the team about the upcoming demo so they don’t forget to prepare.</li></ol><h3>Results</h3><p>Other teams learned about the bot, and from a pet project it transformed into a large-scale one. We had to refactor it. The code was subdivided into modules, modules into blocks, a simple setup mechanism was added. As a result, after massive advertising in general channels, another ten teams adopted Sheldon. Thus, Sheldon became a full-fledged team member.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=95654f33711d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/avitotech/sheldon-a-team-routine-automation-bot-95654f33711d">Sheldon: a team routine automation bot</a> was originally published in <a href="https://medium.com/avitotech">AvitoTech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Load Your JavaScript Library Asynchronously]]></title>
            <link>https://medium.com/@mlanin/load-your-javascript-library-asynchronously-2f2e670efbf1?source=rss-74a578e1cd21------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f2e670efbf1</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Maxim Lanin]]></dc:creator>
            <pubDate>Tue, 01 Mar 2022 07:22:16 GMT</pubDate>
            <atom:updated>2022-03-01T13:18:48.473Z</atom:updated>
            <content:encoded><![CDATA[<p>Let&#39;s imagine, we have a common page:</p><pre><strong>&lt;!DOCTYPE html&gt;</strong><br>&lt;html&gt;<br>  &lt;head&gt;<br>    &lt;script src=&quot;app.js&quot;&gt;&lt;/script&gt;<br>    &lt;script&gt;<br>      App.init(&#39;greeting&#39;, &#39;Hello, John Doe!&#39;);<br>    &lt;/script&gt;<br>  &lt;/head&gt;<br>  &lt;body&gt;<br>    &lt;h1 id=&quot;greeting&quot;&gt;&lt;/h1&gt;<br>  &lt;/body&gt;<br>&lt;/html&gt;</pre><p>With javascript library included:</p><pre><em>// app.js</em><br><strong>const</strong> App <strong>=</strong> {<br>  <em>/**<br>   * Handle already registered actions.<br>   *<br>   * @param  {String} id   Element ID<br>   * @param  {String} name User&#39;s name<br>   */</em><br>  init: <strong>function</strong> (id, name) {<br>    document.getElementById(id).text(name);<br>  }<br>}</pre><p>When your browser loads this page, first of all, it will load and execute your included script, fire init method and then show you the hello message. But problem is, script loading blocks your page, but we want to show it as quickly as possible!</p><p>I think I didn’t tell you anything new and you already know, that it is always better to place such script tags to the very bottom of the body tag.</p><p>But what if I tell you that today it is not the only option?</p><h3>Async way</h3><p>HTML5 brings us a new async attribute for the script tag. If the browser sees this attribute, it will try to load your js file in an async way.</p><p>In our example we can do it like this:</p><pre>&lt;script src=&quot;app.js&quot; async&gt;&lt;/script&gt;<br>&lt;script&gt;<br>    App.init(&#39;greeting&#39;, &#39;Hello, John Doe!&#39;);<br>&lt;/script&gt;</pre><p>Now the browser will show and load our script at the same time. Even if we will add more scripts with the async attribute, they will be loaded together asynchronously.</p><p>The main point in this paragraph is that your page shows instantly without waiting for app.js. So if there are any additional scripts that use your app.js, they may throw an error. Because they can be loaded before app.js itself. That’s why calling App.init() method in this example will throw an error that App is undefined.</p><h3>Solution</h3><p>But what if I tell you that there is a solution that allows us not only to load our script asynchronously but call any actions in it without worrying if our script is already loaded.</p><blockquote><em>Besides, I want to mention that practically all counters and analytic scripts nowadays are made using this approach.</em></blockquote><p>The approach is very easy. We need to check if our app is already loaded, then use it. If not, save all reference history to handle it after the library is finally received by the browser.</p><p>First let&#39;s update our script block that inits the App:</p><pre><strong>let</strong> App = App || [];<br>App.push([&#39;init&#39;, &#39;greeting&#39;, &#39;Hello, John Doe!&#39;]);</pre><p>First line here checks if there is any App already registered. If not, assign a new empty array to it.</p><p>Then push a new array, where #0 element in it is a method name, others are its arguments we want to pass.</p><p>Now we need to update app.js to handle array’s push method and handle history.</p><pre><strong>const</strong> registeredActions = App !== undefined<br>    ? App <br>    : [];</pre><pre><strong>let</strong> App = {<br>  /**<br>   * Handle already registered actions.<br>   *<br>   * <a href="http://twitter.com/param">@param</a>  {String} id   Element ID<br>   * <a href="http://twitter.com/param">@param</a>  {String} text Text to show<br>   */<br>  init: <strong>function</strong>(id, text) {<br>    document.getElementById(id).innerHTML = text;<br>  },</pre><pre>/**<br>   * Implement array&#39;s push method to handle push calls.<br>   *<br>   * <a href="http://twitter.com/param">@param</a>  {Array|Function} item Method call. [methodName, args...]<br>   */<br>  push: <strong>function</strong>(item) {<br>    const functionName = item.shift()<br>    this[functionName].apply(null, item)<br>  },</pre><pre>/**<br>   * Handle already registered actions.<br>   *<br>   * <a href="http://twitter.com/param">@param</a>  {Array} array History of calls<br>   */<br>  _processHistory: <strong>function</strong>(array) {<br>    array.forEach(item =&gt; this.push(item)<br>  }<br>}</pre><pre>App._processHistory(registeredActions)</pre><p>First, we check if there was already App var registered. If it was, then we assume that our library was loaded after we called it first and save history to registeredActions var.</p><p>Then there is App itself with 2 extra methods</p><ul><li>push a proxy between library methods. Simulates array’s push calls;</li><li>_processHistory handles calls’ history.</li></ul><p>At last, we check if there was saved history and process it.</p><h3>Conclusion</h3><p>You can successfully use this technique to speed up loading of your applications.</p><p>Also, it helps you to provide non-blocking js scripts, to include on your customers&#39; sites (if you made one more counter, for example ;))</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f2e670efbf1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data version control in Avito’s Infomodel]]></title>
            <link>https://medium.com/avitotech/data-version-control-in-avitos-infomodel-f0cecadc9752?source=rss-74a578e1cd21------2</link>
            <guid isPermaLink="false">https://medium.com/p/f0cecadc9752</guid>
            <category><![CDATA[highload]]></category>
            <category><![CDATA[data-management]]></category>
            <category><![CDATA[metadata-management]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Maxim Lanin]]></dc:creator>
            <pubDate>Tue, 06 Jul 2021 07:27:09 GMT</pubDate>
            <atom:updated>2021-07-06T07:27:09.658Z</atom:updated>
            <content:encoded><![CDATA[<p>Infomodel is Avito’s metadata management system. It manages ad categorization, taxonomy, and ad directories. Our recent post discussed <a href="https://medium.com/avitotech/metadata-management-system-in-avito-d4db2d6b95b0">how we handle it</a>: why we need Infomodel and how it interacts with the rest of Avito systems.</p><p>Today I will touch upon a no less important issue of working with data — preparing changes and deploying in production.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DsjamuYjy08iQVJMxORuig.png" /></figure><h3>What we used to have</h3><p>In 2017, when we started our work on the Infomodel project, Avito maintained essentially two environments — prod and dev. All Infomodel data was stored in the database. There were no interfaces or processes to modify the data, all edits were made in the code by migrations. We used to code SQL migrations in the main repository of our monolith, adding new records as needed in the tables or modifying those. When deployed, migrations were rolled out by the DBA team in prod or rolled out automatically in dev.</p><p>But there was a hidden problem: what to do if your feature is not ready yet? What if you need to add changes that are going to affect others’ work? To avoid new changes causing trouble, we had an is_active (bool) column used when retrieving data from the database. Here is a category table as an illustration:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b90d52697ee35c6f27df0123569bff0c/href">https://medium.com/media/b90d52697ee35c6f27df0123569bff0c/href</a></iframe><p>To get data from it for building, say, a category tree, we made a simple SELECT query as follows:</p><pre>SELECT * FROM categories WHERE is_active = true;</pre><p>If we wanted to add a new category and hide it for a while, we created a migration in which we inserted a new row and set its is_active to false. After deploying the code in the dev environment, the migration ran automatically and added a new line:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0092ae6131a8d92bf647432fd5f24bc2/href">https://medium.com/media/0092ae6131a8d92bf647432fd5f24bc2/href</a></iframe><p>In the backend, we had to update the query, adding the following to it:</p><pre>SELECT * FROM categories WHERE is_active = true OR category_id = 3;</pre><p>Thus, we had a new category in our local assembly, but others could not see the changes. Then we finished the task and removed the OR. The DBA team switched is_active to true at the subsequent deploy to production.</p><h3>Problem</h3><p>Making frequent changes without involving developers every time is impossible with this approach, especially when it comes to parallel or joint changes.</p><p>But the company is growing, dictating the need for ever more frequent changes, so what shall we do?</p><h3>Solution</h3><p>When we were designing the architecture of Infomodel’s first version, we set ourselves the requirement to give the business the ability to make changes to Infomodel quickly. And, most importantly, to introduce changes so that Avito’s teams did not block each other’s work.</p><p>As a result, we came up with a rather elegant and effective solution that allows teams to:</p><ul><li>work with data in parallel;</li><li>release changes whenever they are ready for it;</li><li>test changes on the fly;</li><li>know who made any changes and when;</li><li>see the difference between one’s changes and what is currently in production.</li></ul><p>We named this solution “Infomodel Version Control.” What does it look like?</p><p>We put Git on top of Postgres. Anyone working with Infomodel works in an isolated branch. In the branch, one can change anything — delete a category, or create a hundred new ones.</p><p>All branching is done from one common production branch called master, which cannot be modified directly. From an interface point of view, introducing new branches looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jP9kdjQAkWrriZrSwoUXHw.png" /></figure><p>We have three different types of branches. Differences between these are related to the release process, which is worth discussing how branching works under the hood.</p><h3>Technical side</h3><p>One of the tasks that we set ourselves in the development of the technical component of version control was simplicity and easy debugging of what is happening with the branches.</p><h4>Data schema</h4><p>To ensure that branches are isolated from each other, we have implemented branching at the Postgres schema level. Each branch is a separate schema with the same set of required tables and records as a master. When creating a new branch, we duplicate the entire master schema. Users work with their own snapshot of data without interfering with others.</p><p>Of course, we had to create a separate scheme for storing service information, such as branch and schema list, user list, etc. There is a separate metadata schema containing the required set of tables supporting Infomodel’s machinery.</p><p><strong>The first task completed</strong>: users can make parallel changes to the data without conflict.</p><p>But there lay the first problem we encountered — primary keys. When creating new records, users also created new rows in tables with autoincrement PK. By adding two different records to two different schemas, they ended up with identical keys, making the entire schema useless. We moved all the sequences into the metadata schema and shared those between the branch schemas. This solved the problem by preventing identical id’s.</p><h4>Change management</h4><p>Similar to Git, we store all changes made by a user. To do this, each schema (including master) has a service table called changelog. This table keeps records for each change in the current branch:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/232d470b2248ddb87d02f9df34c152ca/href">https://medium.com/media/232d470b2248ddb87d02f9df34c152ca/href</a></iframe><p>As you can see from the table, we know who did what and when, and with which entity. As a result, the user can always see in the interface a list of her changes or find and debug someone else’s:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LbAMB04SrYpMJ8I_DczUOw.png" /></figure><p>Let’s imagine that the user wants to delete a category. The category itself and all associated attributes will be deleted in one step. And several entries will be created in the changelog for one user action. To merge these records, we introduced the batch_hash (string) property. Using it, we can identify all the changes made to the database within the same user action. We can also roll back changes one by one using it.</p><p>Thus we have achieved <strong>two more things</strong> — we see all changes and can see the difference.</p><h4>Deploying changes to production</h4><p>The fact that we keep all the changes allows us to merge branches. The exact process of releasing changes in production, as mentioned above, is nothing more than locking the branch for changes and applying entries from the changelog one after another to the entities in the master branch, from where these are deployed to production.</p><p><strong>We let users decide for themselves </strong>when they are ready to push their changes to prod.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bKgTtJg70zH-byeqGz9uAw.png" /></figure><p>Creating branches with a name starting with the Jira task number allows distinguishing branches from each other and linking changes in Infomodel with external changes. We know what PRs were done as part of the task and whether they passed the tests. If not, we prevent the changes from getting released.</p><p>After the release starts, we run a few more test builds before we merge the changes. In this way, product teams can be confident that the change is not going to break anything.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MHbDKYQfxdQDpH87yVGENA.png" /></figure><h4>Branch lag</h4><p>After adding changes from one branch to prod, the rest of the active branches are automatically locked for release. Users can make changes but cannot release them because the branch owner does not see the whole updated picture.</p><p>To fix this, a user can upload master to one’s branch with one click. Under the hood, we will create another clean schema from master and upload all the changes from the previous branch that the user has made. The mechanism is similar to git rebase.</p><p>But there are pitfalls here, too. What if changes have been added to master that delete some of the entities that the user worked with in his branch? The user’s schema will have rows that refer to nonexistent records via a foreign key.</p><p>To solve such problems, we have a tool known as the Garbage Collector. Garbage Collector’s task is to ensure that everything is consistent in the user’s branch and delete records that link to nowhere. It runs after each upload to master. When complete, the tool sends the user notification in Slack about the successful completion of the operation. Changes made by the Garbage Collector are marked with the is_auto (bool) property in the changelog and can be found in the UI using a filter.</p><h3>Testing changes</h3><p>Before releasing the changes, the user may want to see how these look on Avito. To do this, the user can create a test bench for our monolith or her specific service and run his branch. This will allow the backend to switch from master to the given branch and show the result to the user.</p><p>Thus, we have addressed the last item in the specifications, i.e., testing our changes on the fly.</p><h3>Cons of the approach</h3><p>Disadvantages include the lack of a dev environment as such. One instance of Infomodel distributes data to the production environment and all dev environments that link to unreleased branches.</p><p>Another obvious disadvantage is that it is necessary to migrate all existing branch schemas when changing the data schema. Sometimes this causes serious problems considering their number.</p><h3>Results</h3><p>Over the system’s entire lifetime, we created 2226 branches. Of these, 2073 reached the release stage. On average, rolling out one change takes 2 days.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f0cecadc9752" width="1" height="1" alt=""><hr><p><a href="https://medium.com/avitotech/data-version-control-in-avitos-infomodel-f0cecadc9752">Data version control in Avito’s Infomodel</a> was originally published in <a href="https://medium.com/avitotech">AvitoTech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Avito team lead commandments]]></title>
            <link>https://medium.com/avitotech/avito-team-lead-commandments-82e7e802d88f?source=rss-74a578e1cd21------2</link>
            <guid isPermaLink="false">https://medium.com/p/82e7e802d88f</guid>
            <category><![CDATA[teamwork]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[management]]></category>
            <category><![CDATA[leadership]]></category>
            <dc:creator><![CDATA[Maxim Lanin]]></dc:creator>
            <pubDate>Tue, 15 Jun 2021 07:46:38 GMT</pubDate>
            <atom:updated>2021-06-15T07:46:38.611Z</atom:updated>
            <content:encoded><![CDATA[<p>We’ve never posted our internal documents and policies on Medium before, but we’d like to start doing that. So here comes our Team Lead Code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*25Tlk-8a7Fkc4nOrpCIMNA.png" /></figure><h3>1. Never promise anything beyond your control</h3><p>Example: promise to promote a staff member to lead engineer at the following performance review.</p><p>You do not directly control the review outcome. You may have an ideal presentation plan in your head, but the final score depends on many factors and the people involved. Therefore, there is always a risk of not being able to carry out a promise.</p><p>The consequences of this are unpredictable. In the best-case scenario, you lose credibility. In the worst case, you lose a team member.</p><h3>2. Never do another’s work</h3><p>Example: it’s easier for you to solve a problem yourself than to explain to others how to solve it.</p><p>Two problems lurk here simultaneously. The first is about the development of the staff member concerned. What is routine for you is a growth opportunity for someone else. By taking on tasks yourself, you are taking away the chance to grow from your colleagues.</p><p>The second one is <a href="https://medium.com/management-matters/whats-the-bus-factor-of-your-team-and-how-to-increase-it-8bdfb63361fc">the bass factor</a>. By doing other people’s work, you become a point of functional failure. When you become a manager, you lose control of your time. Sooner or later, you will fail the task and wreck the sprint/roadmap/OKR.</p><p>Delegate as much as possible! Do you want to code? Take on tasks that are not directly related to performance targets or those that will improve your team’s productivity.</p><h3>3. The corridor problem</h3><p>Example: a staff member has taken on a task, but he attacks you with “how-to” questions whenever a challenge arises.</p><p>The corridor problem becomes a real threat when the staff member attempts to shove off responsibility for a complex issue. By giving specific hints, you accept this. And even if you come up with a working solution right away, the staff member will only be responsible for the implementation, but if a problem arises as a result, it will fall on your shoulders. I’m sure that you have enough of your own issues.</p><h3>4. The right to mistake</h3><p>You’re not perfect, and neither are your team members. Everyone can make a wrong decision, which backfires at a later time. The important thing is knowing how to deal with mistakes. Not thinking and not analyzing the consequences is bad. But if you learn a lesson from each mistake and no longer repeat it, this means growing experience.</p><p>Never take away the right to make mistakes from your team! Otherwise, they will be afraid to make decisions, try to do everything perfectly, and spend a lot of time on it, not having time to do something equally important.</p><h3>5. Don’t be afraid to admit your mistake</h3><p>Example: you have decided on how to work on a project. Over time, you notice that the project is going in the wrong direction, more and more problems arise, and customer dissatisfaction grows. But you try not to pay attention to it because a lot of time and resources have already been invested, and the team will not understand. As a result, the project will bring even more problems and, in the end, may become a complete failure.</p><p>You won’t always be right. There are no people who are never wrong. Unfortunately, there are people who puff out their chests and say, “I always thought so,” and then quit just before the complete failure.</p><p>Don’t hesitate to acknowledge a problem. It always is better to stop in time and turn 180 degrees than attack a rock and take your whole team with you.</p><h3>6. Don’t be afraid to stop being a friend</h3><p>Example: you are promoted to a team lead in a team where you are used to being on equal footing. You try to act as before, but a routine task arrives that needs to be delegated to someone. But nobody wants it. You try to push, but you are one of them. How can you do it?</p><p>Leadership implies confrontation. As you know from your own experience, people are not always enthusiastic about new requirements or tasks. Sooner or later, you will have to press, criticize, and even fire people.</p><p>Being a friend of your subordinates will make this even harder. The sooner you find balance in keeping a distance, the better for you and for them. For starters, skip having lunch with them once. Let them talk about you.</p><h3>7. Do not criticize the person, criticize the result</h3><p>By criticizing a person, you hurt their self-esteem. The person you criticize can retreat into herself, hide in his shell and be frustrated, or begin to defend himself, which will lead to arguments that will not help the situation in any way.</p><p>Compare the two wordings: “you are irresponsible” and “you have failed a critical task for a second time.” The two sound different.</p><p>If you want to criticize, give specific figures. These are much more difficult to argue with.</p><h3>8. Don’t be afraid to give negative feedback</h3><p>Don’t take negative feedback as a punishment. This will make it difficult to give negative feedback, and you will constantly try to smooth the corners.</p><p>It will help if you give negative feedback from a growth perspective. There is a problem, but no one tries to scold the team member for this. Instead, think together about how to fix the situation.</p><p>Do not give negative feedback too softly — it will not be clear that the feedback is negative. For example, you say: “This could have been done better.” Your listener does not have your context, and with a high probability, he will interpret this as “you are doing everything well, but you can still improve.” Then he will think that the quality of his work suits everyone. He is not willing to overtax himself to improve his performance, so nothing will be done. Instead, say: “I see a problem here. Let’s discuss it.” But remember #5 above!</p><h3>9. Too many second chances</h3><p>When giving another “second chance”, remember about the balance.</p><p>If you do not give a second chance, you deny the right to make mistakes and be imperfect. We all make mistakes, and we all have weaknesses.</p><p>But giving too many “second chances” when someone makes the same mistake regularly and does not learn from it is simply indulging slovenliness. No one works in a vacuum: the team sees the difference between their behavior and that person’s behavior. By avoiding addressing the problem, you demotivate the team and send them a message that they can screw up as much as they want, and nothing will happen.</p><h3>10. Hiring the right person</h3><p>When hiring, try to maintain a balance. Recruitment often takes a very long time, because we start looking for the perfect candidate. It is difficult, time-consuming, and not always necessary.</p><p>How to recruit correctly? Ask yourself a question: “What demand should the prospective employee’s knowledge and skills address?” Then, add questions to the interview list that will purposefully test whether the candidate has the competencies you are looking for.</p><p>Try to understand the lifetime of the problem. If it is resolved after 2–3 months, what will the candidate with the given skill set do afterward in the team? Will he be productive? After thinking about the future, add to the checklist a check that the candidate will still be useful.</p><p>Before making a hiring decision, the final step is to check if the candidate is the right candidate for your goals. Not the most extraordinary candidate, not the one you like most, but the one who will solve the problem.</p><h3>11. Don’t compromise when hiring</h3><p>“Being wrong and not hiring a good candidate is better than being wrong and hiring a bad one.”</p><p>A bad employee will do less good and potentially more harm and take away the time that you could invest in a good employee. Feeling sorry for the bad, you punish the good. The same logic applies when firing.</p><h3>12. When discussing a situation, do not take sides</h3><p>Do not get involved in the problem but try to remain an outside observer. This will allow you to maintain objectivity, solve the problem, and not support one side at the expense of the other.</p><h3>13. Do not hesitate to repeat how you understood your opponent</h3><p>Rephrasing the discussion in your own words in the form of a summary is a good way to ensure that you have not missed anything and have understood the interlocutor correctly. For example, after listening to your opponent, you can say: “Let me summarize what you said” and sum up the main points. This will allow the listener to make sure that you understand her correctly, and you will reduce the risk of information distortion.</p><h3>14. Everyone has a different context</h3><p>Remember that everyone thinks differently, and everyone has different motivators. If something drives you, it does not necessarily drive another.</p><p>What is perfectly obvious to you may not be clear to your opponent. Everyone has different experiences, backgrounds, and knowledge gaps.</p><h3>15. Last but not least: don’t forget about yourself</h3><p>You lead a team to success. A team lead who has burned out and lost motivation will not lead the team to a good result. Sooner or later, guys will notice this and lose motivation themselves.</p><p>Don’t forget about yourself. Build boundaries between work and personal life. Do not try to do everything everywhere, please everyone, learn to say no, and just rest. More importantly, don’t take the team’s output personally. The task entrusted by you will not always be solved ideally or even well from your perspective. Let it be. You shouldn’t feel responsible for every single line written by each team member. Get involved in fixing critical crashes, but don’t let a poorly done task rob you of healthy sleep.</p><p>Please share in the comments what you agree and disagree with. Share what commandments are missing and whether your company has similar guidelines.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=82e7e802d88f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/avitotech/avito-team-lead-commandments-82e7e802d88f">Avito team lead commandments</a> was originally published in <a href="https://medium.com/avitotech">AvitoTech</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An Easy Way To Debug Your Laravel API]]></title>
            <link>https://medium.com/@mlanin/debug-your-laravel-api-155da37b24fe?source=rss-74a578e1cd21------2</link>
            <guid isPermaLink="false">https://medium.com/p/155da37b24fe</guid>
            <category><![CDATA[debugging]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[laravel]]></category>
            <dc:creator><![CDATA[Maxim Lanin]]></dc:creator>
            <pubDate>Tue, 25 Apr 2017 07:20:47 GMT</pubDate>
            <atom:updated>2017-06-26T07:46:23.574Z</atom:updated>
            <content:encoded><![CDATA[<p>If you ever develop an API, recall how many times you wanted to dump a variable, or find out what SQL queries were processed during your request, or even fetch a list of HTTP calls to third-party APIs?</p><p>First need is easily solved by Laravel’s dd() helper, but it will completely corrupt JSON output and break all your API consumers.</p><p>Second one can’t be solved by the core itself and you will have to listen to queries/requests and log them somehow by your own.</p><p>To solve this issues couple of years ago I made a small package that resolves them in just two lines of code: <a href="https://github.com/mlanin/laravel-api-debugger"><strong>lanin/laravel-api-debugger</strong></a>. And after its recent update I decided to tell you about it.</p><p>Complete installation guide can be found in the repo of the project. Here I want to tell you how it works, how to use it, and how it can make your life a bit easier.</p><p>First of all this package was written to debug my API right on production servers. Since API was serving its methods to thousands of clients I couldn’t just dd() something or make any sort of xdebug magic. Also due to security restrictions (and our IT team logic) production DB was accessible only from that server, so debugging on local env was not an option too. For the first couple of times I decided to write dump to the log, but soon enough understood that it was quite annoying not search what I need in the rapidly growing log file.</p><p>So I decided to make a tiny lib that will store all my required dumps during request and then just slightly update resulting JSON response by adding debug attribute with all debug info in it. With this approach response will not be broken and I can quickly sniff out what’s happening on the server.</p><p>Lets imagine you have an API method that returns array of posts as a root attribute and you clients consume it to show the list. With this lib you can dump any variable wherever you need like this:</p><pre>$foo = &#39;foo&#39;;<br>$bar = [1, 2, &#39;bar&#39;];<br><br>// Call Debugger through a lad helper.<br>lad($foo, $bar);</pre><p>And response will be updated like this:</p><pre>{<br>  &quot;posts&quot;: [<br>    ...<br>  ],<br>  &quot;debug&quot;: {<br>    &quot;dump&quot;: [<br>      &quot;foo&quot;,<br>      [<br>        1,<br>        2,<br>        &quot;bar&quot;<br>      ]<br>    ]<br>  }<br>}</pre><p>As you can see, resulting answer wasn’t corrupted, it is still readable, and at the same time you can find all debug you need.</p><p>After a month of usage with this project, library was extracted to the separate open source package in order to be required in other API applications and started evolving in what it is now.</p><p>First of all I wanted to add SQL queries logging, that should be super handy during development. And so I did!</p><p>When service is booting it inits QueriesCollection that starts to listen to Laravel database connection events, saves every query, formats them and return as the separate attribute in response like this:</p><pre>{<br>  &quot;result&quot;: [<br>    ...<br>  ],<br>  &quot;debug&quot;: {<br>    &quot;database&quot;: {<br>      &quot;total&quot;: 2,<br>      &quot;items&quot;: [<br>        {<br>          &quot;query&quot;: &quot;select * from `users` where `email` = &#39;<a href="/service/mailto:john.doe@acme.com">john.doe@acme.com</a>&#39; limit 1;&quot;,<br>          &quot;time&quot;: 0.38<br>        },<br>        {<br>          &quot;query&quot;: &quot;select * from `posts` where `author` = &#39;1&#39;;&quot;,<br>          &quot;time&quot;: 1.34<br>        }<br>      ]<br>    }<br>  }<br>}</pre><p>As you can see, all SQL bindings were injected into query string and execution time was also added.</p><blockquote>It is worth to notice that this DB log will be added <strong>ONLY</strong> when you have you debug mode on: APP_DEBUG=true so that nobody can see your queries in production state.</blockquote><p>Using this approach you can also extend you debug collections and add whatever info you want. Like Guzzle requests info, event calls, or queue requests. How collections work you can find in the package itself and it is quite easy to implement.</p><h4>Update #1</h4><p>Last week I released a new version that adds even more. New you can profile actions and see cache hit stats. For more info, look it the readme of the package.</p><p>If you have any questions or requests, fill free to contribute to the package!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=155da37b24fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>