<?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 Güneş Maboçoğlu on Medium]]></title>
        <description><![CDATA[Stories by Güneş Maboçoğlu on Medium]]></description>
        <link>https://medium.com/@gunesmab?source=rss-90ef0b97c439------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*F01aX3dE590TyuR-r6wKOw.jpeg</url>
            <title>Stories by Güneş Maboçoğlu on Medium</title>
            <link>https://medium.com/@gunesmab?source=rss-90ef0b97c439------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 10:17:52 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gunesmab/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[MVVM]]></title>
            <link>https://gunesmab.medium.com/mvvm-9af7ff4a55ca?source=rss-90ef0b97c439------2</link>
            <guid isPermaLink="false">https://medium.com/p/9af7ff4a55ca</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[mvvm]]></category>
            <category><![CDATA[object-oriented-design]]></category>
            <category><![CDATA[design-patterns]]></category>
            <dc:creator><![CDATA[Güneş Maboçoğlu]]></dc:creator>
            <pubDate>Mon, 16 Aug 2021 08:29:33 GMT</pubDate>
            <atom:updated>2021-08-16T08:29:33.835Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*_DMvajfGcKQoIOWpLysa1Q.png" /></figure><p>In this article I will try to explain MVVM from my point of view as far as I can. In my opinion, to learn a piece of information, it is necessary to understand why we need it and how it meets our needs. That’s why at first I’m going to try to explain why we need architecture and design patterns.</p><h3><strong>Why do we need design patterns?</strong></h3><p>The software products are under constant change and development. Every change and development is shaped depending on the structure before it. This structure is the sum of the solutions to the problems we encounter.</p><p>The problems in software projects and their solutions are based on abstract concepts. That’s why finding solutions to problems becomes much harder. So we need rules to make abstract concepts more concrete. In fact the design patterns are grouped versions of these rules. The more solutions we implement according to these design patterns, the more understandable the code will be and the easier it will be to make future improvements.</p><h3><strong>Why layer-based design pattern?</strong></h3><p>First of all many design patterns can be used in an application. But here I will talk about the design pattern selection which forms the basis of the application.</p><p>I will try to explain why we need to use the layer-based design pattern through the general workflow. Take, for example, a banking application. Let’s assume that there is a request from the product manager: “Users should be able to apply for a loan from the mobile application”. Business analysts examine this request and determine business rules such as how much credit users can apply and what information users will be asked to fill in. UX/UI designers, on the other hand, determine how the information will be displayed and how the information will be received from the users following these business rules. From this point of view, we see two different sets of rules: one is business, the other is UI. If we divide the application according to these two main layers, we can both better understand the needs of other teams while developing the application, and we will code it more easily. Also when a change is requested, we find easily the parts which will be changed.</p><h3><strong>MVVM</strong></h3><p>I mentioned above that the layers form the basis of an application. Now I will try to explain the equivalents of these layers in the <em>MVVM</em> design pattern. Before going into detail, I want to give you a small warning. The <em>MVVM</em> design pattern tells us on which layers we need to put the functions and how these layers should communicate with each other. It does not promise anything beyond that.</p><h4>Business Logic — Model</h4><p>Data types (UserName, Password, etc), access to data, business rules applied to these data are defined in this layer. For example, if you are logging into the application with a nickname, the nickname object itself and the rules to create it are defined in this layer. For the design decision of the classes defined here, DDD and Primitive Obsession topics can be examined.</p><ul><li><strong>Domain Driven Design(DDD)</strong>: In short, it is a design that suggests building business logic oriented classes. It aims avoiding technical terms and structures, so that classes will depend on the workflow terminology. In this way everyone who has domain knowledge can more easily understand the work done by the business logic in the project. Thus it helps strengthening the communication between the product experts and the development team.</li><li><strong>Primitive Obsession</strong>: It is an anti-pattern which can be described as the use of primitives instead of small objects for simple concepts. Let’s assume that we are storing password entered by the user. We usually store this information in the String type. But in fact the password has more properties than the String type. Assume that based on business rules the password must be at least 6 character long and must include one numeric character. These are verification rules that do not exist in the String type itself. In other words, a separate type must be defined in which the rules and properties of the password concept are defined.</li></ul><h4>UI Logic — View-ViewModel</h4><h4><strong>ViewModel</strong></h4><p><em>ViewModel</em> generally adapts the information coming from the <em>Model</em> layer to the <em>View.</em> That is where the display rules are modeled. The <em>View</em> directly communicates with the <em>ViewModel</em>. The <em>ViewModel</em> communicates with the <em>Model</em> layer. Actions from <em>View</em> are interpreted here. For example, let’s assume that we show a list of currencies on the screen. If a currency has risen, we need to code this rule in the <em>ViewModel,</em> if we want to show it green.</p><h4>View</h4><p>Application-based processes (OS-related processes, animations) are defined here. The <em>View</em> side must contain as less logic as possible. It should only adjust itself according to the signals it receives from the <em>ViewModel</em>. Using Data Binding will be very useful in keeping this layer as dummy as possible.</p><h4>Communication Between Layers</h4><p>We talked about the definitions of the layers. So how should these layers communicate with each other? The biggest difference that separates the <em>MVVM</em> from <em>MVC</em> and <em>MVP</em> is that the communication between layers is done using the <em>observable</em> pattern. In this way the <em>Model</em> does not know the <em>ViewModel</em>, and the <em>ViewModel</em> does not know the <em>View</em>. In other words, thanks to the <em>observable</em> pattern, we build a one-sided dependency. No layer is affected by the vast majority of changes in the next layer. In this way refactoring is much easier. Likewise, one layer can be used by more than one class on the next layer. For example, more than one <em>ViewModel</em> can depend on the same <em>Model</em>. As a result, if we can model these layers properly. We can make changes such as UI layouts with a very little touch.<br>While establishing the connection between these layers, we should not ignore the concept of “Loose Coupling”. For this, you can examine the <em>LoD</em> design guideline.</p><p>These layers are not the layers that indicate a certain class. Instead, these are abstract semantic layers. For example, let’s design a product detail screen. Although it might seem natural to create a class for each layer such as <em>ProductDetailModel</em>, <em>ProductDetailViewModel</em>, and <em>ProductDetailView</em>, it’s not necessary at all. Often we need to divide these layers into sublayers with different design patterns. Beside any class in any layer might depend on more than one class in the previous layer.</p><p>Let’s think of a screen consisting of 2 different fields where login credentials are entered and a currency list is displayed. The fact that these two fields are displayed in the same window does not mean that the data of these two fields should be kept in the same <em>ViewModel</em>. Displaying these two fields in the same window may make sense in terms of UX. But in terms of software, they are two views completely independent of each other. Therefore, in such a scenario, we need to divide the logic into 2 different structures: <em>LoginView</em>-<em>LoginViewModel</em>-<em>LoginModel</em> and <em>CurrencyView</em>-<em>CurrencyViewModel</em>-<em>CurrencyModel</em>. So, from a software perspective displaying them in the same window does not mean anything.</p><p>To sum up, these layers are completely abstract. When creating the classes that make up these layers, we must always keep in mind other software principles. The <em>MVVM</em> design pattern tells us on which layers we need to put the functions used in the application and how these layers should communicate with each other at a high level. It does not promise anything beyond that.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9af7ff4a55ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Helpful Clean Coding Tips]]></title>
            <link>https://gunesmab.medium.com/helpful-clean-coding-tips-abaf8626e418?source=rss-90ef0b97c439------2</link>
            <guid isPermaLink="false">https://medium.com/p/abaf8626e418</guid>
            <category><![CDATA[object-oriented-design]]></category>
            <category><![CDATA[coding-tips]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Güneş Maboçoğlu]]></dc:creator>
            <pubDate>Tue, 22 Dec 2020 06:06:01 GMT</pubDate>
            <atom:updated>2020-12-22T07:05:03.665Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W1JTRcPb3EM5zR4h6l_tQw.jpeg" /></figure><p>I will try to mention some software design topics which I think are important. These are:</p><ul><li>Law of Demeter</li><li>Single Responsibility Principle</li><li>Composition over Inheritance</li><li>Primitive Obsession</li><li>Listen to Tests</li><li>Use Dependency Injection Technique</li></ul><h3>Law of Demeter(LoD)</h3><p>LoD is a design guideline for developing software whose rules and benefits can be summarized as:</p><p><strong>Rules (</strong>based on <a href="https://en.wikipedia.org/wiki/Law_of_Demeter">Wikipedia</a><strong>):</strong></p><ul><li>Each class must be able to access to another class only the information and resources that are necessary for its legitimate purpose.</li><li>Each unit should have only limited knowledge about other units.</li><li>Each unit should only talk to its friends; don’t talk to strangers.</li></ul><p><strong>Benefits:</strong></p><ul><li>It gives full control over class properties. You cannot change any property from outside of its class context.</li><li>It makes loose coupling relations over classes.</li><li>It makes it easier to refactor code.</li></ul><p>Let’s think about that we are working on a client application. The classes in the project are as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2f569f1d1e31810a7895419db7c05da4/href">https://medium.com/media/2f569f1d1e31810a7895419db7c05da4/href</a></iframe><p>I only want to add NumericFilter to the PasswordView. To make this, I have to add the filter to EditableTextView and have to know how EditableTextView keeps filters.</p><ul><li>All of this information creates an unnecessary dependency between Screen and EditableTextView. Thus these classes are coupled now. Whenever we want to change PasswordView or EditableTextView filter mechanism, we must update the Screen class also.</li><li>How can we add restriction to the functionality of adding a filter to PasswordView or EditableTextView? For example, how can I prevent adding AlphanumericFilter to PasswordView? As you can see we have no control over filters.</li></ul><p>How must we implement these classes?</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9db114bd9f7550b8dca48248e8626803/href">https://medium.com/media/9db114bd9f7550b8dca48248e8626803/href</a></iframe><ul><li>I don’t need any knowledge about EditableTextView to use PasswordView.</li><li>I can have full control over adding filter.</li><li>Any changes to EditableTextView implementation do not affectPasswordView api.</li></ul><h3>Single Responsibility Principle(SRP)</h3><p>What does responsibility mean in the <em>SRP</em> concept? Assume that we need a telephone class. While we creating it, we want to stick by the <em>SRP</em>. That’s why let’s start with the writing responsibilities of a telephone.</p><ul><li>Must be able to send text messages.</li><li>Must be able to make a call.</li><li>Must be able to connect to the internet.</li></ul><p>…</p><p>It goes like this. As you can see, there are many responsibilities. So how can we stick to the <em>SRP</em> in the presence of a lot of responsibilities? Could we be making a mistake when defining the concept of responsibility?<br>Let’s look at Robert C. Martin’s definition:</p><blockquote>Martin defines a responsibility as a reason to change,<br>and concludes that a class or module should have one, and only one, reason to be changed (e.g. rewritten).</blockquote><p>It means implementations of each responsibility(or we can call this duty) must be defined in somewhere else.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/06e0997bbdc540ea2696d86526da100e/href">https://medium.com/media/06e0997bbdc540ea2696d86526da100e/href</a></iframe><p>In case these functions need to be changed, we have to refactor the Telephone class. That’s it, it violates the <em>SRP</em>. To be compatible with the <em>SRP</em>, we have to construct Telephone class as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1325710512f149b19ae2e1d00a883dbf/href">https://medium.com/media/1325710512f149b19ae2e1d00a883dbf/href</a></iframe><p>Any of VoiceSignalManager, TextMessageSignalManager, or NetworkManager implementation changes do not affect to Telephone class. So our Telephone class is compatible with the <em>SRP</em>.</p><p>All of these are eligible to function definitions as much as class.</p><h3>Composition over Inheritance</h3><p>How can we decide to choose between composition or inheritance? Which one is the best practice? It is quite simple, the answer relies on this question, which kind of relationship is there between classes, is there a “<em>has-a</em>” relationship or an “<em>is-a</em>” relationship? If the answer is there is an “<em>is-a</em>” relationship then the best practice is inheritance, otherwise composition.</p><ul><li>What is an “is-a” relationship? A taxi is a vehicle also a bus is a vehicle too. (inheritance)</li><li>What is a “has-a” relationship? A taxi has an engine. (composition)</li></ul><p>It seems very easy to decide but in practice it’s not that easy. Many times we go in the wrong direction. At which point do we make the mistake?</p><p>Let’s continue with another example. Imagine we are working on a client application that has different screens.</p><p>There is TextInputView class:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3d52a54741a95929727150ebedcc6638/href">https://medium.com/media/3d52a54741a95929727150ebedcc6638/href</a></iframe><p>Then let’s add a day and night theme to it now.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e765e5ad146c77ca3e2698f97e6ae1ec/href">https://medium.com/media/e765e5ad146c77ca3e2698f97e6ae1ec/href</a></iframe><p>Is there something wrong with the class structure above? If there is then what is it? Let’s answer the “<em>is-a</em>” and “<em>has-a</em>” questions.</p><ul><li>Are NightThemedTextInputView and DayThemedTextInputView a ThemedTextInputView? Yes.</li><li>Is ThemedTextInputView a TextInputView? Yes.</li><li>Is Theme is a TextInputView? No.</li><li>Is DayTheme is a ThemedTextInputView? No.</li><li>Is NightTheme is a ThemedTextInputView? No.</li><li>Has TextInputView a Theme? No.</li></ul><p>Here starts our mistake…</p><ul><li>Has ThemedTextInputView a Theme? Yes.</li><li>Has DayThemedTextInputView a Theme? Yes.</li><li>Has NightThemedTextInputView a Theme? Yes.</li></ul><p>If ThemedTextInputView, DayThemedTextInputView and NightThemedTextInputView all have Theme then why we inherit from ThemedTextInputView to construct NightThemedTextInputView and DayThemedTextInputView? Even if NightThemedTextInputView and DayThemedTextInputView are a ThemedTextInputView, we cannot inherit Theme attribute. This is the trap which is seen many times. In order not to fall into this trap we need to know we cannot inherit a function that has a “<em>has-a</em>” relationship.</p><p>So ThemedTextInputView should be like this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ebd2da2f806929b90b38deb8e827b4a4/href">https://medium.com/media/ebd2da2f806929b90b38deb8e827b4a4/href</a></iframe><h3>Primitive Obsession</h3><p>It shortly means leaving type safety out. Credit card, email, date, password, URL and many others. This kind of information mostly stored as String. All kinds of logic which are related to all of this information mostly put in Utility classes.</p><p>Alright, why is putting this kind of information in Utility classes wrong, what is the best practice in this situation? Let’s think about date information.</p><p>Date information could be stored in many forms, such as only day, just month or whole date. It could be some part of the whole date, or complete. It could have different formats too. Can we understand all of this information just by looking at the variable name?</p><pre>var creditCardExpirationDate: String</pre><p>If you know about credit cards, you can easily say that the “creditCardExpirationDate” variable has to store month and year. But can you tell what its format is, is it “11/2024” or is it “11/24”? So this is not type-safe. Therefore we need to create CreditCardExpiryDate which is tailored for this purpose.</p><p>If we are working on a date, there must be a Date class. This kind of information has more attributes than primitives thus we have to define them as a type.</p><h3>Listen to Tests</h3><p>If writing a test is difficult, then you must think twice about your class structure. The cause is most likely because it violates one or more software concept(this is often the “single responsibility” rule). This tells us writing unit test is the best teacher about clean coding.</p><h3>Use Dependency Injection</h3><p>Use dependency injection to make it easier to apply the rules and techniques above to your project.</p><ul><li>It makes circular dependencies visible.</li><li>It makes the classes loosely coupled.</li></ul><p>Use dependency injection framework.</p><ul><li>It reduces boilerplate code</li><li>It makes class creations easier.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=abaf8626e418" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Discussion On How Kotlin Extension Functions Can Be Used]]></title>
            <link>https://gunesmab.medium.com/a-discussion-on-how-kotlin-extension-functions-can-be-used-1ff4da3549b6?source=rss-90ef0b97c439------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ff4da3549b6</guid>
            <category><![CDATA[kotlin-extension]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[object-oriented-design]]></category>
            <category><![CDATA[object-oriented]]></category>
            <dc:creator><![CDATA[Güneş Maboçoğlu]]></dc:creator>
            <pubDate>Tue, 01 Dec 2020 09:59:45 GMT</pubDate>
            <atom:updated>2020-12-01T09:59:45.648Z</atom:updated>
            <content:encoded><![CDATA[<p>The extension functions should have a task related to the responsibility of the respective class. One of the most common mistakes made by developers is to write extension functions like a utility function. Here is an example to explain this better:</p><pre>fun String.validateEmail(): Boolean {<br>    //validation process<br>    return result<br>}</pre><p>These types of functions should not be defined as extension functions. Storing the e-mail information as String does not mean that String class is associated with the e-mail information. Instead this validation should reside in a class like EmailValidator.</p><pre>class EmailValidator {<br>    fun validate(email: String): Boolean {<br>        //validation process<br>        return result<br>    }<br>}</pre><p>fun CharSequence.IsEmpty(): Boolean function defined in the Kotlin library is a good example for use of Kotlin extension function. Actually CharSequence interface is a special version of the char array. Judging from this aspect, isEmpty function would be a natural member of the CharSequence class.</p><p>At this point I will go a little beyond the purpose of the article and ask the following question: How should we interpret two functions below?</p><pre>fun &lt;C, R&gt; C.ifEmpty(defaultValue: () -&gt; R): R where C : CharSequence, C : R = ....</pre><pre>class ArrayList {<br>    @Override<br>    public void forEach(Consumer&lt;? super E&gt; action) {...}<br>}</pre><p>CharSequence and ArrayList classes can be considered as different varieties of the array data structure. The functionalities above, forEach and ifEmpty, do not belong to these classes. We can see this in the clearest in forEach function. Neither the consumer class nor the loop type nor the operations of what to do with list items are directly related to the array data structure. How to define such functions should be questioned more.</p><p>Kotlin extension functions can be defined in a kotlin file or as a member of a class. Extension functions defined in a kotlin file could be used any where in the project, we can call this <em>global scope</em>. On the other hand, the extension functions defined inside a class can only be called from the scope of its class. To call these functions from another class, run or with functions can be used.</p><p>So, what is the difference between defining extension functions within global scope and defining them within a class scope? To explain the difference between them without touching upon extension functions defined within global scope, I will just try to explain the one defined within <em>class scope</em> first. I will be using home brewing as an example to explain this part. Home brewers already know it but for those who have no idea let me you some idea about it. For fermentation the yeast must be kept for a period of time in an environment with the appropriate temperature adjusted for its type. This can be coded as below by using extension function.</p><pre>class Refrigerator {<br>    fun start() {}<br>    fun stop() {}<br>}</pre><pre>class RefrigeratorBeerScope {<br>    fun Refrigerator.adjustSuitableTemperatureForYeast() {<br>        //...<br>    }<br>}</pre><pre>class Application {<br>    fun main() {<br>        //In this section, the refrigerator works traditionally<br>        val refrigerator = Refrigerator()<br>        refrigerator.start()<br>        refrigerator.stop()<br>        <em>with </em>(RefrigeratorBeerScope()) <strong>{<br>            </strong>//At this point, the refrigerator is now working for yeast fermentation.<br>            refrigerator.adjustSuitableTemperatureForYeast()<br>        <strong>}<br>        </strong>//RefrigeratorBeerScope is ends, and adjustTemperatureToKeepYeastSuitableTemperature extension function cannot be called any longer.<br>        refrigerator.adjustTemperatureToKeepYeastSuitableTemperature()//this code cannot be compiled<br>    }<br>}</pre><p>What I want to explain with this example is that I have added new behavior to the refrigerator for a certain purpose. When the brewing process is over, we have achieved our goal. From this point on, the refrigerator can continue to be used traditionally.</p><p>Now, I want to continue with forEach function which I mentioned above.</p><pre>class CollectionIterationScope {<br>    fun &lt;E&gt; List&lt;E&gt;.forEach(consumer: Consumer&lt;E&gt;) { ... }</pre><pre>    fun &lt;E&gt; List&lt;E&gt;.iterator(): Iterator&lt;E&gt; { ... }</pre><pre>    fun &lt;E&gt; Set&lt;E&gt;.forEach(consumer: Consumer&lt;E&gt;) { ... }<br>    ...<br>}</pre><pre>...<br>val list = ArrayList()<br>with(CollectionIterationScope()) <strong>{<br>    </strong>list.forEach <strong>{ </strong>... <strong>}<br>    ...</strong></pre><pre><strong>}<br></strong>...</pre><p>Of course, this type of use will be a bit of a challenge. Most of the developers will choose to use the forEach method instead. What I want to talk about using the extension function defined in the class is not how easy it is to implement, but how it makes it easy to group functions successfully.</p><p>Let’s continue with another example:</p><pre>class CreditCardUtil {<br>    fun getCreditCardType(creditCardNumber: String): CreditCardType<br>    fun isCardNumberValid(creditCardNumber: String): Boolean<br>    ...<br>}</pre><pre>or could be</pre><pre>class StringCreditCardNumberScope {<br>    fun String.getCreditCardType(): CreditCardType<br>    fun String.isValidCardNumber(): Boolean<br>    ....<br>}</pre><p>I know these examples are not good enough. I just try to give a new perspective and start a discussion. What I want to touch on is that some classes may need to gain new behaviors or new attributes under certain conditions. Let’s continue with Collection.kt interface, it extends Iterable.kt interface. Of course, there is nothing strange about this. But let’s consider what would happen if the Collection.kt interface did not extend the Iterable.kt interface. In this case can we say that Collection.kt interface is no longer a collection? Can different implementations of Iterable.kt interface be not grouped in any other way? How would it be if CollectionIterationScope.kt was used instead? On the other hand, there are some attributes that make a difference. For example, when add method is added to List.kt interface, it turns into MutableList.kt interface.</p><pre>fun addEmail() {<br>    val emails = <em>mutableListOf</em>&lt;String&gt;()<br>    <em>with</em>(MutableCollectionAsyncScope()) <strong>{<br>        </strong>emails.<em>asyncAdd</em>(&quot;&quot;)<br>    <strong>}<br></strong>}</pre><pre>class MutableCollectionAsyncScope {<br>    fun &lt;E&gt; MutableCollection&lt;E&gt;.asyncAdd(element: E) {<br>        Executors.newSingleThreadExecutor().execute <strong>{<br>            </strong>add(element)<br>        <strong>}<br>    </strong>}<br>}</pre><p>The same functionality could also be achieved using proxy pattern.(like AsyncCollection.kt class). However there is a conceptual difference between them. The proxy pattern is combining collection and asynchronously working attributes. If I have to summarize, most developers, while constructing a class, combine the main defining features that characterize the class with the secondary defining features that may be actually related to another class. I’m not saying that is wrong, I want to start a discussion on how to design better classes, better architectures and better patterns using kotlin extension functions.</p><p><em>I would like to thank </em><a href="https://medium.com/u/a4db81fd86cc"><em>Gizem Burhanoglu</em></a><em> for giving me the idea for this article.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ff4da3549b6" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>