<?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 Andrea Passaglia on Medium]]></title>
        <description><![CDATA[Stories by Andrea Passaglia on Medium]]></description>
        <link>https://medium.com/@gurghet?source=rss-1ef70af547d0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*spp2xNzhVLopupNEEjE_9g.png</url>
            <title>Stories by Andrea Passaglia on Medium</title>
            <link>https://medium.com/@gurghet?source=rss-1ef70af547d0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 19:54:37 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gurghet/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[Domain Driven Design for Web Apps an Illustrative Example]]></title>
            <link>https://medium.com/@gurghet/domain-driven-design-for-web-apps-an-illustrative-example-f3e3bbcc89cb?source=rss-1ef70af547d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/f3e3bbcc89cb</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[domain-driven-development]]></category>
            <dc:creator><![CDATA[Andrea Passaglia]]></dc:creator>
            <pubDate>Fri, 22 Jan 2016 22:51:11 GMT</pubDate>
            <atom:updated>2016-01-22T23:10:41.005Z</atom:updated>
            <content:encoded><![CDATA[<p>Our example application is something we are all familiar with in some way. I’m going to illustrate how to design a simple e-commerce application that sells fashion articles for highly glamorous people of accomplished status.</p><p>I’m being specific as much as I can because much of the decisions will have to be driven by domain knowledge. And no, there is no escape there. As much as you’d love to delve into the code we have to stress that everyone in the team has to share a good amount of domain knowledge in the vector that Eric Evans calls <strong>Ubiquitous Language</strong>.</p><p>A simple architecture that I love using is an evolution of MVC the Model View Presenter. It fits well our needs because the Presenter does not “control” the system, it merely “presents” it, peeling off from all domain responsibilities and returning them to the <strong>Model</strong>.</p><p>Let’s get started with a simple presenter for a listing of shoes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*-e56Ym9YNy_tyWFEn02h8w.png" /></figure><p>Let’s start slow. What did I just code?</p><p>What you see is the ShoeListing class with just the constructor implemented. There are two things to note already. The class name is a narrow specification of what the class is in charge to do: present a shoe listing. The other thing is we are <strong>injecting</strong> a service. This is an access service we are going to use to make sure the user is logged in and can access a specific resource.</p><p>We are not injecting the model or the view. Weird ah? But think about it.</p><ol><li>It makes the class a little lighter when <strong>unit testing</strong></li><li>If you are using more than one repository it gives you more flexibility and a <strong>slimmer constructor</strong></li><li>It encourages <strong>view modularization</strong>. Especially if you are not using a framework (and especially if you <em>are</em> using a framework!)</li></ol><p>Here is our first method in the ShoeListingPresenter</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*oHDAcgqV2ihWVAFKgrVe8Q.png" /></figure><p>What I’m going to do instead is a bottom-up approach to describe all the little details.</p><ul><li>The name of the function is just ‘<em>show</em>’, it’s pretty <strong>generic</strong>. That’s because the name of the class is <strong>explicative</strong> enough.</li><li>The real parameter is the <strong>color</strong>. The repository and the view are just pluggable.</li><li>The method of the access service is <strong>notLoggedIn</strong>, it’s easier to read than a boolean ! at the beginning.</li><li>There is a little bit of <strong>procedural style code</strong> to add objects to the grid, but that’s ok because this is part of the presentation logic.</li><li>You can see some more presentation logic to <strong>calculate</strong> the number of rows for the grid.</li></ul><p>As a side note, we assume that the shoe object is ready to be displayed but that may not be the case. The presenter should extract from the shoe the necessary attributes to display it, like an image path or a picture width.</p><p>Let me now expand a little bit.</p><p>The Bounded Context we are operating in right now is the front-end. A shoe listing might well has its own baggage of implied information in it. Shoes are to a person like frame is to a canvas, so designers decided to show them in little wooden frames (how imaginative.) Their representation is different enough that it’s simply wrong to write the difference in a ‘if-else’ statement. That’s why they deserve their own presentation class.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f3e3bbcc89cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mechanical Keyboards: Style Up Your Desktop]]></title>
            <link>https://medium.com/@gurghet/mechanical-keyboards-style-up-your-desktop-41d22ab2ec4c?source=rss-1ef70af547d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/41d22ab2ec4c</guid>
            <category><![CDATA[keyboard]]></category>
            <category><![CDATA[tech]]></category>
            <dc:creator><![CDATA[Andrea Passaglia]]></dc:creator>
            <pubDate>Wed, 13 Jan 2016 13:54:40 GMT</pubDate>
            <atom:updated>2016-01-13T13:54:40.975Z</atom:updated>
            <cc:license>http://creativecommons.org/publicdomain/zero/1.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N4WF0BnDvksv5N1JbxUaxA.jpeg" /></figure><p>If you play video games or have a 9-to-5 job, you most likely spend hours every day typing on your keyboard. That’s thousands of hours a year! That’s why is very important to have some basic ergonomics while at your desk. If done extensively and improperly, typing alone can cause all sorts of injuries to hands and wrists.</p><p>Unfortunately the vast majority of keyboards sold today, are not designed with ergonomics in mind and thus don’t help a lot in preventing things like carpal tunnel syndrome and repetitive strain injuries.</p><p>Your keyboard is most likely a “rubber dome” keyboard. This means that under every key there is a rubber dome that, while pressed, close a circuit so that a letter can be displayed on the screen. This is the most inexpensive type of keyboard but sadly it doesn’t give much of a feedback and it makes your finger exert more force that is necessary to register, often bottoming out the key.</p><p>If you are a gamer of a fast typer you have another problem: you simply can’t press more than two keys at a time. This means that you can’t press key combinations that require three keys, or even type too quickly without loosing keys from time to time, worst of all you can’t emulate a piano.</p><p>A third thing you should know is that your keyboard layout was designed for typewriters in the ’70, not the funk music type of seventies, more like the Franco-Prussian War type. Back then the main issue was to avoid clashes and jams between the the levers, not ergonomics!</p><p>Worst of all, most rubber dome keyboard are plain ugly. They just sit there and pour out ugliness into your desk. Won’t you rather have something that reflect a little bit of your style? Or maybe you have a drawer to hide it when you are not using it.</p><p>But there is hope. The main reason cheap keyboards continue to be popular is for market reasons. They are cheap. And people are familiar with them. Luckily there is a world out there with better, more ergonomic, beautiful keyboards.</p><p>I’m going to address all the three issues I brought up. Tactile feedback, more presses simultaneously and layout. I will also present you with some cool colorful keyboards.</p><h3>Tactile Feedback</h3><p>As I said, rubber dome keyboards don’t offer much of a feedback while typing. On the other hand, mechanical keyboards, keyboards with actual mechanisms behind each key, are much easier on your fingers and will let you know with visual, auditory and tactile feedback when the key is going to register.</p><p>Prior to 1990 the majority of the keyboards were mechanical, like the popular IBM model M. That was because having a computer was serious business and people who invested $5 000 in a computer would make sure the main input device was up to the task.</p><p>So what is so different about the tactile feedback of mechanical keyboards? Actually a lot. It’s like blowing your nose with a pizza place napkin instead of a linen handkerchief. It’s a totally different experience! If your finger-brain system start to receive some consistent feedback when pressing keys your way of typing will change for the better. As a matter of fact, having a hint <em>before</em> the key actually register will set up a virtuous circle which will give a chance to your finger to not bottom out every time.</p><p>All this will put less strain on your hands and will reduce the overall fatigue. But every person is different and has different tastes, the variety in key switches is accordingly big. Some switches require more force, others are louder, some click, others are dampened.</p><h3>Style</h3><p>Speaking of tastes. The other main thing about a keyboard is undeniably its style. Mechanical keyboards are easily customizable. Because every key is a sub-device on its own, you can pull the keycap and move it around or change it a fair amount of times without problems. There is a vast community of keycaps out there and personally I think about it like changing clothes to your keyboards. If you touch-type like me you can even disregard the letters printed on them and put blank keycaps or print your owns, make some art with your keyboard. I brought one of my keyboards at work and I immediately received many comments about it and how colorful it was, in this respect it’s very fun.</p><p>There are many shops online like <a href="http://pimpmykeyboard.com/">Pimp My Keyboard</a> or <a href="https://www.massdrop.com/mechanical-keyboards">Massdrop</a> in which you can start looking around to get an idea of what the current trends are. One of my favourite keycaps set is the DSA Retro which is made of superior grade plastic and feels wonderful to the touch. The font is inspired to the Commodore 64 and it certainly has a warm personality. DSA refers to the shape or profile of the caps which are uniform instead of slightly slanted like most keyboards.</p><p>Keycaps is not the only thing you can personalize. In fact there is a variety of shapes and cases your keyboard can come in. With or without num pad? You can even get rid of the arrows and function buttons if you are a minimalist, with a design called 60% keyboard. As your taste get finer you start to appreciate weird more exotic shapes. From the ultra-minimalist 40% to the ultra ergonomic butterfly. In the final stage you design your own case and send it to 3D printing yourself.</p><p>In the next article I will explain some basics of tactile feedback which I gave a general introduction and I will compare it to the common rubber dome.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41d22ab2ec4c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The MVP (Model View Presenter) Architecture]]></title>
            <link>https://medium.com/@gurghet/the-mvp-model-view-presenter-architecture-8c87d21ce044?source=rss-1ef70af547d0------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c87d21ce044</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[domain-driven-design]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Andrea Passaglia]]></dc:creator>
            <pubDate>Sat, 19 Dec 2015 18:12:51 GMT</pubDate>
            <atom:updated>2016-01-14T13:20:36.635Z</atom:updated>
            <cc:license>http://creativecommons.org/licenses/by/4.0/</cc:license>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*6XHd8piv3mPwBMjI7_2qkg.png" /><figcaption>The Taligent proposal for the new software architecture</figcaption></figure><h4>and how it relates to the MVC and all his variants</h4><p>In his primordial form the MVC pattern had the main intent of modularize a graphical application or a graphical component in three main sub-units each with a separate set of concerns. The value of such division is to improve code clearness of intent and thus a higher maintainability.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CnE2QbHmP2R8iFkQgFrE6Q.png" /></figure><p>In the earlier MVC we had a complete circle in which the controller processed the input and fiddled the model to change its state, this change is messaged to the view that update itself and waits for further interaction from the user which will be passed to the controller and so another cycle begins.</p><p>I would argue that even if the system is now more modular, the three components are still coupled. In fact they have a cyclic dependency that theoretically is a bad symptom if you are looking for low coupling.</p><p>With time the MVC evolved, especially thanks to the web and the Struts 2 framework it morphed into a horseshoe, lowering coupling between the model and the view through the use of more generic ways for the view to retrieve data from the model, adding a layer of indirection between the two. This way you can switch between views and expect a common interface.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*elWr3df4yI9YrfAR43LxUw.png" /></figure><p>The MVP architectural pattern was born about 20 years later and featured a lot of further modularization of the MVC beyond separating the model and the view even further.</p><p>It originally replaced the controller with the presenter and added Commands, Selections and the Interactor in the data flow. The presenter is seen as a collection point of <strong>events</strong>. The <strong>Interactor </strong>is placed between the view and the presenter and is a filter that turn raw interface events like “user clicked the save button” into user intentions by contextualising them. The <strong>Commands </strong>specify the available operations one can perform on a specified S<strong>election</strong>. Selections answer to the question “how do I specify my data?” This using a DDD repository would translate for example in a method like `findByColour` so I can retrieve a set of object to operate on all of the same colour.</p><p>According to this early model, the view still communicates with the model. Of course using a distributed notification system is nice but it still requires a data access <em>from </em>the view. This means? Yep, you guessed it, coupling between the model and the view. This is sooo practical right? I want the name of a user displayed on the screen, I just write</p><pre>public void displayUser() {<br> print(model.getUserFullName());<br>}</pre><p>and don’t forget we also have mobile user who don’t want to see the full name because they have small screens so it’ll be enough for them to print the first name.</p><pre>public void displayUser() {<br> print(model.getUserFirstName());<br>}</pre><p>Right? Except now we support Chinese, Spanish and Russian and the API for getting the name changed. The concept for name is more generalized and specialized at the same time: there is <em>longName</em>, <em>shortName</em>, <em>surname</em>, <em>patrnonimic</em>, <em>name[0]</em>, <em>name[3]</em>, etc. We update the mobile view but we forget to update the web view and so our view is partly broken. The interface guys try to fix it but they don’t have permission to do so because displaying a legal name in the invoices is not part of their knowledge, it’s part of the domain knowledge. We mixed some domain knowledge in the views. What if we did</p><pre>public void displayUser(String name) {<br> print(name);<br>}</pre><p>we would have a view with most of the specification left at deeper level, so that one would have to write at least an `if` statement to distinguish between different view types. This would achieve full decoupling but would leave some view concerns inside the model. A good compromise could be to establish a `Name` concept at the presentation level and have it shared as Ubiquitous Language term.</p><pre>public void displayUser(Name name) {<br> print(name.short());<br>}</pre><p>and in the invoice view:</p><pre>public void displayUser(Name name) {<br> print(name.legal());<br>}</pre><p>This way a reasonable amount of knowledge is expected to be shared by everyone, leaving much of the detail on how a legal name is formed to some domain class.<br>Now the model can change abruptively and the only thing that gets changed would be the presenter, views can remain completely unchanged.</p><p>Selectors are really some facilities built upon repositories like the aforementioned `findByColour` that could be something like this:</p><pre>public List findByColour(String aColour) {<br> Colour colour = new Colour(aColour);<br> List allIceCreams = getIceCreamRepository().fetchAll();<br> return allIceCreams.stream()<br> .filter(iceCream -&gt; iceCream.colour.equals(colour)<br> .collect(Collectors.toList());<br>}</pre><p>Commands in their simplest form are a list of things I can do with the data I gathered. When I have all my red coloured ice-creams I want to put them in the truck. I extend a Command interface for doing this:</p><pre>public class LoadIceCreamCommand implements Command {<br> private final List iceCreams;<br> private final Truck truck;</pre><pre> // some factory methods to create a proper command<br> // and populate the attributes above…<br> <br> @Override<br> public void execute() throw IceCreamLoadingException {<br> truck.load(iceCreams);<br> }<br> <br> @Override<br> public void undo() throw UndoException {<br> truck.unload(iceCreams);<br> }<br>}</pre><p>Commands are thus a finite set of classes each of which contains domain knowledge. They directly manipulate domain classes and can be passed around sufficiently easily. It’s worth to note that the command does not contain logic to <em>select</em> data from the database. Whether we chose the ice-creams by color or by flavour is totally irrelevant to the command. `LoadIceCreamCommand` can load <em>any</em> set of ice-creams into <em>any</em> truck. A cons is that we have to make explicit whether these arguments are already validated (or we can decide to double-check.)</p><p>Let’s put everything together to see how the whole system works and let’s also try to interpret this pattern with DDD.</p><p>Iscream is a food firm that sells ice-creams, its business mission statement is to scare his customer in as many ways as possible. One of the things this company does is to sell ice-creams of one flavour instead of the requested flavour, and it tricks customers by swapping flavours with the same colour like mint and pistachio or almond and butter pecan.</p><p>The presenter is a receptacle of business methods, and is also at application level, so is a natural place to initiate things like `loadSimilarColorOnTruck` presented here as it was written with the java Spring framework</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8e59f6b30519c01995c7a7d00c8da6e3/href">https://medium.com/media/8e59f6b30519c01995c7a7d00c8da6e3/href</a></iframe><p>Here we see how everything fits together, the presenter, selectors, commands, the view and the model. We leave leave the interactor for a part two…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c87d21ce044" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>