<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: liskov</title>
    <description>The latest articles on DEV Community by liskov (@liskov).</description>
    <link>https://dev.to/liskov</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F541417%2F36190e6c-c61c-44df-a989-e78a7bedc47c.png</url>
      <title>DEV Community: liskov</title>
      <link>https://dev.to/liskov</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/liskov"/>
    <language>en</language>
    <item>
      <title>Kotlin Emojis Riddle 😈</title>
      <dc:creator>liskov</dc:creator>
      <pubDate>Thu, 25 Mar 2021 16:36:26 +0000</pubDate>
      <link>https://dev.to/sanga/kotlin-emojis-riddle-11k8</link>
      <guid>https://dev.to/sanga/kotlin-emojis-riddle-11k8</guid>
      <description>&lt;p&gt;What's wrong with this Kotlin code?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;val emojis = listOf(“❤️️“, “🍔”)
val emojiIndex = someNullableInt ?: 0 % (emojis.size - 1)
val selectedEmoji = emojis[emojiIndex]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Faex5d135usno79fs2znz.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Faex5d135usno79fs2znz.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's decompile it to java code:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;List emojis = CollectionsKt.listOf(new String[]{“❤️️“, “🍔”})
int emojiIndex = someNullableInt != null ? someNullableInt : 0 % (this.emojis.size() - 1);
String selectedEmoji = (String)this.emojis.get(emojiIndex);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Can you see the problem now?&lt;/p&gt;

&lt;p&gt;the answer is below, don't look straight away :)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fruqlql1k3w469iej053o.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fruqlql1k3w469iej053o.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Answer:
&lt;/h2&gt;

&lt;p&gt;In case someNullableInt is not null, emojiIndex will be assigned with the original value of someNullableInt and not its modulo.&lt;br&gt;
This can cause indexOutOfBoundException.&lt;/p&gt;
&lt;h2&gt;
  
  
  how can we fix it?
&lt;/h2&gt;

&lt;p&gt;the answer is below, don't look straight away :)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fruqlql1k3w469iej053o.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fruqlql1k3w469iej053o.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To fix it we need to add () around someNullableInt ?: 0 -&amp;gt;&lt;br&gt;
&lt;br&gt;
 &lt;code&gt;val emojiIndex = (someNullableInt ?: 0) % (emojis.size - 1)&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;Which will compile to the following java code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;List emojis = CollectionsKt.listOf(new String[]{“❤️️“, “🍔”})
int emojiIndex = (someNullableInt != null ? someNullableInt : 0) % (this.emojis.size() - 1);
String selectedEmoji = (String)this.emojis.get(emojiIndex);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;as you can see, now it will do modulo as expected. Case solved.&lt;/p&gt;

&lt;h3&gt;
  
  
  Thank you for reading, look for our next Byte
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Made with ❤️ by &lt;a href="https://www.sanga.app" rel="noopener noreferrer"&gt;Sanga&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>kotlin</category>
      <category>riddle</category>
      <category>bug</category>
      <category>sanga</category>
    </item>
    <item>
      <title>Cross platform object oriented design 💣💥💥</title>
      <dc:creator>liskov</dc:creator>
      <pubDate>Wed, 10 Feb 2021 08:38:42 +0000</pubDate>
      <link>https://dev.to/sanga/cross-platform-object-oriented-design-211l</link>
      <guid>https://dev.to/sanga/cross-platform-object-oriented-design-211l</guid>
      <description>&lt;p&gt;Confused about too many names for the same property? &lt;/p&gt;

&lt;p&gt;Tired of remembering all names other teams gave to the same feature?&lt;/p&gt;

&lt;h2&gt;
  
  
  Lisko, please give an example:
&lt;/h2&gt;

&lt;p&gt;A good example from the industry is "String template":&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;iOS developers call it "String interpolation"&lt;/li&gt;
&lt;li&gt;Kotlin developers call it "String template"&lt;/li&gt;
&lt;li&gt;Javascript developers call it "Template literals".&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But it is the same thing, like this giraffe. The only thing that changes is your point of view.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5a2k8777wrg6hxtljj4b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5a2k8777wrg6hxtljj4b.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Shared architecture - same name on every stack
&lt;/h2&gt;

&lt;p&gt;We at Sanga first encounter this issue with our IOS &amp;lt;-&amp;gt; backend&lt;br&gt;
architectures and communications between them. When we saw it work &lt;br&gt;
perfectly and without any misunderstanding we applied it to other sides &lt;br&gt;
of our dev stack such as our frontend sphere, and it fitted like a glove. &lt;/p&gt;

&lt;p&gt;The universal design language we created:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Contracts - The objects that pass between our stack parts&lt;/li&gt;
&lt;li&gt;View Layer - Controllers, the topmost layer that creates an interface to be consumed (can be UI in an iOS app or REST API in a µservice)&lt;/li&gt;
&lt;li&gt;Service - Business logic layer&lt;/li&gt;
&lt;li&gt;Repository - Responsible for CRUD operations on our model.&lt;/li&gt;
&lt;li&gt;Factory - Responsible for Converting Contracts to Models and vice versa.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fi8vqmfrqtnxuydjo8e5j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fi8vqmfrqtnxuydjo8e5j.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9ifxjkh3amvv27umqcpd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F9ifxjkh3amvv27umqcpd.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Shared code
&lt;/h2&gt;

&lt;p&gt;Shared architecture makes it possible to have a shared code.&lt;/p&gt;

&lt;p&gt;We are currently on our journey to find the right way to share code between the different stack layers - but I wouldn't conclude it yet - as we didn't solve this question yet. when we do it will be one hell of a byte!&lt;/p&gt;

&lt;h3&gt;
  
  
  Thank you for reading, look for our next Byte
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Made with ❤️ by &lt;a href="https://www.sanga.app" rel="noopener noreferrer"&gt;Sanga&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Monorepo</title>
      <dc:creator>liskov</dc:creator>
      <pubDate>Wed, 20 Jan 2021 14:43:57 +0000</pubDate>
      <link>https://dev.to/sanga/monorepo-f4c</link>
      <guid>https://dev.to/sanga/monorepo-f4c</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vVPxvKu0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3p5x5lwsk9h75bxf8xwi.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vVPxvKu0--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/3p5x5lwsk9h75bxf8xwi.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  what?
&lt;/h2&gt;

&lt;p&gt;Monorepo is when putting code of several micro-projects in one code repository.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://i.giphy.com/media/l2JeiCp90TpSSUOU8/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/l2JeiCp90TpSSUOU8/giphy.gif" alt="Alt text of image"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  So it's kind of a Monolith?
&lt;/h2&gt;

&lt;p&gt;Well, that's the missing part of the micro-service architecture.&lt;/p&gt;

&lt;p&gt;Splitting our code into micro-projects, each with its own tests, deployment, scaling, etc., introduces a new challenge of maintaining and using many microcode repositories.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Monorepo will hold the collection of micro-project while sharing the echo system of testing, deploying, etc.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  when?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;When your team needs to run fast -&amp;gt; faster -&amp;gt; fastest.&lt;/li&gt;
&lt;li&gt;When there are too many repositories and no one understands what/where they are and if their dependency versions are aligned.&lt;/li&gt;
&lt;li&gt;When small library change follows with 30 PR's on 30 git repositories (was the story of my life).&lt;/li&gt;
&lt;li&gt;When there are a small number of teams working together because when there are a greater number 
of teams working on the same git repository, it can do worse than better.
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When -&amp;gt; &lt;code&gt;now()&lt;/code&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Things to consider while working with a mono repo:
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Per micro project build&amp;amp;deploy:

&lt;ul&gt;
&lt;li&gt;use &lt;code&gt;git diff&lt;/code&gt; to find out what directory changed&lt;/li&gt;
&lt;li&gt;build&amp;amp;deploy only this part&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Code owners:

&lt;ul&gt;
&lt;li&gt;what team is responsible for what part of the code?&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Generate micro project script:

&lt;ul&gt;
&lt;li&gt;Creating new microservice should be done in seconds(take a look at &lt;a href="https://yeoman.io"&gt;https://yeoman.io&lt;/a&gt;)&lt;/li&gt;
&lt;li&gt;Each new microservice should be built automatically by the same standard as all other services&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Contract lib:

&lt;ul&gt;
&lt;li&gt;All services contracts speak in the same language: Rest/Grpc/etc...&lt;/li&gt;
&lt;li&gt;All services use the same libraries with no duplicate code.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Listen to our CTO, Matan Lachmish, talks about Monorepos on &lt;a href="https://open.spotify.com/episode/4xw3LQiPIr9bs0rCms0Rhm?si=WEZgvNGXR3C7ODlgNfWhgQ"&gt;Developing Symptoms podcast&lt;/a&gt; (for Hebrew speakers)
&lt;/h4&gt;

&lt;h3&gt;
  
  
  Thank you for reading, look for our next Byte
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Made with ❤️ by &lt;a href="https://www.sanga.app"&gt;Sanga&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>monorepo</category>
      <category>sanga</category>
      <category>git</category>
    </item>
  </channel>
</rss>
