<?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 Michael Tran (mytee) on Medium]]></title>
        <description><![CDATA[Stories by Michael Tran (mytee) on Medium]]></description>
        <link>https://medium.com/@mytee?source=rss-50d37084b3ca------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*SvtZPS6-zbpwD3f4.jpg</url>
            <title>Stories by Michael Tran (mytee) on Medium</title>
            <link>https://medium.com/@mytee?source=rss-50d37084b3ca------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 20:28:59 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mytee/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[UI first]]></title>
            <link>https://mytee.medium.com/ui-first-7d4b9a26a8d8?source=rss-50d37084b3ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d4b9a26a8d8</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Michael Tran (mytee)]]></dc:creator>
            <pubDate>Fri, 09 Aug 2019 05:12:00 GMT</pubDate>
            <atom:updated>2019-08-25T12:14:57.622Z</atom:updated>
            <content:encoded><![CDATA[<p>Starting new apps from UI</p><p>Starting from 2015, my team partners and I always focused to the UI first. We delivered the apps within shorted time and never failed. How it works?</p><p>After listening to the client with their idea of how the app should work. We asked the most important question: <strong><em>How should it look like</em></strong>.</p><p><em>Note that there are like million apps on Appstore and PlayStore. When the clients have the business idea, they are more or less visualizing it with similar apps. The question “how it looks like” will drive them back to picture it in mind.</em></p><p>The answer will be like: “the login part is like Google +”, “the posting part is like FB”, “the display part is like …”.</p><p><em>From there, we can work out the idea of how the business likes. It would be in the line of advertising; or in the line of social media … It is 80% on this and 20% on that.</em></p><p>Lets check the real cases.</p><h3>Case 1:</h3><p>The client came with an idea of building a world where people can share, like, re-load other posts, list and sell their items among their circles using the credit points that can be traded with real money.</p><p>How should it look like? We asked. The answers eventually leaded to somethings like 70% of FB, 10% of G+, 50% of Ebay and 30% of Bitcoint.</p><p>Here is the steps we do in our team:</p><p>1- We put the above apps together in a table.</p><p>2- We break the apps in many components. * Component, not features.</p><p>3- We match the components with the apps.</p><p>4- We put the components in the new app.</p><p>and looks like this as a sample</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/546/1*kNxlLIDTARWGRPFf1I0krA.png" /><figcaption>The table in fact is much longer. It is for the idea</figcaption></figure><p>The table in fact is much longer. It is for the idea.</p><p>We allocated 3 developers in this app, and planed it for 2 sprints -4 weeks- . Why only 3? We already built many reusable components. We just worked on the portion of adjustment to match with new app.</p><p>Why need 3? We always have 2 developers in same task, the main developer can do up to 90% of the work, the pair developer will do only 10%. This helps that this developer will know what he participated, and can take over when needed.</p><p>Why the 3rd person? often he is the PM, who will participate and anticipate for the work to ensure it will be done in time. We found from experience that most developers are inward character. They dont make themselves clear in plain English. They speak programming languages. The PM in general can fill in the gap, reword it, clarify the issues and help solve the hip cut.</p><p>Why 4 week delivery? With component development approach. We reuse the components and form the app by lego-put them together. The new app will form by many components with certain changes only. Lets look at the table again before we go to next discussion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/777/1*4YoJA8wKNHVIfiq2xyOZCg.png" /></figure><p>You can use 1 developer to do the new app. It is your call. We just share our experience and approach. It works with us.</p><h4>Lest go backward to the protocol, server, database and hosting.</h4><p>Why backward? We dont define data table, api yet. We work them out from the UI.</p><p>Lets pick the Remote authentication component. User must input user name and password? We have 2 visible fields, 1 hidden token field and an Rest API Encrypted POST call, that should return something from server. If it fails, then we must go to forgot password or register new user.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*27pZ4HNDPhm_TTOvHTVIVQ.png" /></figure><p>The user registration screen will have username, email, password, address, and later bank account, credit card etc for buying/selling items and trading credit/coint. From there we can define our Rest server and data table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/887/1*27IHgzR7Mzsn70LP4jDKTQ.png" /></figure><p>For the hosting, we know this app will have multi users and parallel processing as well as real time transaction. We just need to work out what database support parallel processing. No SAP, no Progress as they are sequential. Perhaps MySQL or MondoDB?</p><p>The Hosting system must have load balancing and auto scaling? AWS have both, Azure has LB only. Perhaps AWS?</p><h3>Case 2:</h3><p>The client want to have an app that allow carer logins, checks in, picks+locks a job, starts timer, stops timer, does feedback, reports issues, gets patient signed off the job, gets patient rate the performance satisfaction …</p><p>Mind you, we never ask “how it works?”. We dont want to understand the business behind, we will never do as much as the client wanted us to. We go to our technique. We asked: “How should it look like?”.</p><p>It is 40% of FB, 10% of G+, 60% of carer app …With the client help, we worked out together that the app will have screen with username and password or faceid/finger print login/checkin. A screen of listing jobs that user can pick … we did a few mockup screens with wireframe app. We use the table looks like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*sl3_1zFrbi_n3Dy5VGFXnQ.png" /></figure><p>In 4 weeks, we presented to the client a working prototype with dummy data. After made few changes as the client request, after 8 weeks, we presented a working app with real data from a nodejs server with mongoDB. The Rest APIs are derived from the UI working backward. The json database is formed from the data sending to the Rest server. We worked backward from UI here.</p><p><em>It might be worth to explain again. If we dont go from the UI, we will need a long time to understand the client requirement and the business. The fact is, to be able to go to the idea of the app, the client have been in the business for many years. That is why in the old day, developers take real long time to develop a system since they must understand the business idea, then go to do the data tables first, then server, then protocol and finally the UI.</em></p><p>We are in modern time, we dont have to know the business, we just need to know how it looks to the user. We do the UI first, then derive the protocol of what to send and receive to/from server, then form json data tables thru the Rest channel.</p><p>The rest server and Json database are portable, we just simply deploy them in the client’s hosting server at later stage.</p><p>Currently, we use Fastlane to test and deploy our Android and IOS apps. We use Lighthouse with the Webapp. We use SourceTree as client, server with Bitbucket with pipelines/bamboo for CI/CD. We use Firebase for the Notification and Enterprise deployment. We use Agile and Jira for our team. The bosses might decide to change any or all them later, then we change. The technology is changing anyway.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d4b9a26a8d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[10 minutes Push Notification Swift 5]]></title>
            <link>https://mytee.medium.com/10-minutes-push-notification-swift-5-61845490a77c?source=rss-50d37084b3ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/61845490a77c</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[push-notification]]></category>
            <category><![CDATA[server-push]]></category>
            <category><![CDATA[apn]]></category>
            <dc:creator><![CDATA[Michael Tran (mytee)]]></dc:creator>
            <pubDate>Mon, 05 Aug 2019 07:45:12 GMT</pubDate>
            <atom:updated>2019-08-09T01:14:57.597Z</atom:updated>
            <content:encoded><![CDATA[<h3>Push Notification Swift 5</h3><p>Swift 5, APN client and server</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/64/0*k0PS5IfpkDqrd6k8" /></figure><p>Client and server for Apple Push notification with Swift 5. Supplement for the lecture week 6.</p><p>Not to repeat the lecture. The following are practical side of the class.</p><h3>Prepare for the client</h3><p>1- Ask user for permission — either silent or non-silent notification -.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a362c74175a2b486ae72fdb5ebf6c13c/href">https://medium.com/media/a362c74175a2b486ae72fdb5ebf6c13c/href</a></iframe><p>Add the code from line 2 to 8 in the func as above. It will pop a dialog box to ask user for permission.</p><p>2- Register the app with APN server.</p><p>Add these 3 functions to the end of AppDelegate.Swift, before the last }</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/567e5b1f73080b953f33fc9315ea4842/href">https://medium.com/media/567e5b1f73080b953f33fc9315ea4842/href</a></iframe><p>3- Enable background task with Remote Push,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/0*mbJ74bSB4FYm1Z-_.png" /></figure><p>and also Push service.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mKNJvv11nFV9-oh7.png" /></figure><p>If you find any error at this step, then likely you didnt do the preparation steps at the Apple developer site for</p><ul><li>app ID: It must be specific, no * in app ID</li><li>Push certificates for development. The distribution is optional until you plan to release the app.</li><li>download and import the certificate</li><li>download and import the provisional profile that matches with the app id. Without this, your xcode will refuse compiling</li><li>run the app on real device, not emulator</li></ul><p>4- Add the codes at</p><ul><li>add “import UserNotifications” to the top of AppDelegate and your main viewcontroller</li><li>add to viewDidLoad()</li></ul><p>UNUserNotificationCenter.current().delegate = self;</p><ul><li>to the end of you viewcontroler, so that you can deal with the notification while app is in foreground</li></ul><p><em>extension ViewController: UNUserNotificationCenterDelegate {</em></p><p><em>func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: </em><a href="http://twitter.com/escaping"><em>@escaping</em></a><em> (UNNotificationPresentationOptions) -&gt; Void) {<br> print(notification.request.content.body);<br> completionHandler([.alert, .sound])<br> }}</em></p><h3>Prepare for the Push server.</h3><p>It is worth to note again that we need our own server to send our push notification request to Apple Push server, which inturn sends the push notification to our app. We dont have any alternative send the notification directly to the app.</p><ul><li>The first step is to create and download the P8 file. It will download something like AuthKey_Z692H6MNDF.p8. The Z692H6MNDF is the key ID, will be used to send the Push.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ecU5CHmWOLnChh2L.png" /></figure><p>We have 2 options. We can either download the test server from Khoa Pham, <a href="/service/mailto:onmyway133@gmail.com">onmyway133@gmail.com</a>. This guy is just great. His server can run on multi platform. Download here <a href="https://github.com/onmyway133/PushNotifications/releases">https://github.com/onmyway133/PushNotifications/releases</a>.</p><p>You can review the preparation process in his github as well <a href="https://github.com/onmyway133/PushNotifications">https://github.com/onmyway133/PushNotifications</a>.</p><p>Add the p8 file, key ID, and your team id into the test server app as illustrated in the link above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/0*7ibapAs1k_-rse0J" /></figure><p>You will also need your bundle ID and device token as shown in step 2 when you run the app.</p><p>Let review the lecture note for this section.</p><ul><li>The p8 file, the key ID and team ID are to get authenticated to Apple Push server, which will decide to continue to process the request body.</li><li>The bundle ID to determine which app to send the notification to; The device token to determine which phone device should receive the notification.</li><li>The body payload is how the notification should be seen as Apple doc specified <a href="https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html">https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CreatingtheNotificationPayload.html</a>. Note that there are several ways to present the payload.</li></ul><p><em>We can actually do some fancy things with payload and notification UI/service templates. This could be covered in a lecture at later stage.</em></p><p>Or you can make your own Push server with Nodejs <a href="https://github.com/node-apn/node-apn">https://github.com/node-apn/node-apn</a>.</p><p>You dont have to use the many year old examples with pem files. In fact, just</p><p>1- Create a directory, open a terminal there.</p><p>2- Run “npm install apn — save” at the terminal.</p><p>3- Save this code to a file, say server.js</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/67cacaf0ad3137c089f8c4c57282c838/href">https://medium.com/media/67cacaf0ad3137c089f8c4c57282c838/href</a></iframe><p>4- Copy your p8 file into this directory.</p><p>5- Edit the file, use your key, key id and team id at lines 5, 6, 7.</p><p>6- Edit line 13 for the token.</p><p>7- Line 23 for the Bundle ID.</p><p>8- run “node server.js” at the terminal.</p><p>You should expect to receive the notification on your device.</p><p>The server can use express, mongodb to register the device token once, next time, you dont have to send it again. With an id, ie mobile phone registration. You can get the saved token from the mongodb to send the notification to the device.</p><p>There is another option is to use Firebase Cloud Messaging service so you can send notification to both IOS and Android but it is not covered in this note.</p><p>The sample code is at <a href="https://github.com/myteeNatanwit/pushTest">https://github.com/myteeNatanwit/pushTest</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61845490a77c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A team or a group]]></title>
            <link>https://mytee.medium.com/a-team-or-a-group-3c37d3b6fada?source=rss-50d37084b3ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c37d3b6fada</guid>
            <category><![CDATA[agile]]></category>
            <dc:creator><![CDATA[Michael Tran (mytee)]]></dc:creator>
            <pubDate>Mon, 01 Apr 2019 02:15:59 GMT</pubDate>
            <atom:updated>2019-04-01T02:18:48.502Z</atom:updated>
            <content:encoded><![CDATA[<p>Group of individual coders or a team of developers?</p><p>Say you have a few apps to be provided in a couple of months. You also have a few developers in hand. There are 2 choices: Form a group or build a team.</p><p>Option 1: Group - Assign one developer to one app. Assign some to the server or database in associate with their skill set.</p><p>Option 2: Team — The whole team will work together to analyze the apps, break them down into components and self-assign to the components that match best with individual skill set. Team by default joins force to do the work as one unit.</p><p>The idea of option 1 will be:</p><ul><li>easy to manage. You -the manager or team lead — know who is doing what and can follow up one to one in single problem.</li><li>one hold the knowledge. Anything about the app, you ask the developer who did the app. He can fix the bug and add new feature faster than anyone as it is his own work.</li><li>high risk on individual. If one developer left, the equal skills person will be hard to get and learning curve will be long.</li><li>time wasting for documenting as everyone has different skills and logic.</li><li>duplicate work across the apps/projects.</li></ul><p>The idea of option 2 will be:</p><ul><li>Agile management approach. Transparent works between team members.</li><li>component development. The components will be re-used across the apps. No duplicate work will be done between the team.</li><li>team holds the knowledge. Everyone knows the work of other in all apps/projects as the work is inter-changed. Component based development allows team member inter-change.</li><li>inter-change work for the share components between team.</li><li>low risk, easy to get new member and short time to become productive.</li></ul><p>The mentality of the logic:</p><p>2 network, 1 db, 1 server, 2 web are not a team. If they dont work together as a team, they are a group of individual who works in the same project.</p><p>Try to think about a football team. All of them can play football. They can actually replace each other in most of the cases. The role each plays in the team is different only because the individual can contribute to the team better with the role.</p><p><a href="https://medium.com/@mytee/do-the-right-way-with-team-work-a277026c8552">Teamwork</a> bases on <a href="https://medium.com/@mytee/do-the-right-way-with-component-b1cb72247993">component development</a> not task.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c37d3b6fada" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Simple callBack]]></title>
            <link>https://mytee.medium.com/android-simple-callback-d2623181a7a3?source=rss-50d37084b3ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/d2623181a7a3</guid>
            <category><![CDATA[callback]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[closure]]></category>
            <dc:creator><![CDATA[Michael Tran (mytee)]]></dc:creator>
            <pubDate>Sun, 31 Mar 2019 02:20:10 GMT</pubDate>
            <atom:updated>2019-05-19T23:44:49.158Z</atom:updated>
            <content:encoded><![CDATA[<p>Static callBack structure</p><p>1- Create a global interface file, say myCallBackInterface.java with content like this:</p><p>package com.yourPackage</p><p>//define callback interface<br>public interface MyCallbackInterface {<br> public abstract void onDownloadFinished(String result);<br>}</p><p><strong><em>Note that the abstract method means this has to be overridden.</em></strong></p><p>2- Define the callBack func in your Main activity, say like this:</p><p>MyCallbackInterface callback = new MyCallbackInterface() {<br><a href="http://twitter.com/Override">@Override</a><br>public void onDownloadFinished(String result) {<em>// … your code here. ie. handle the result like process the string result …</em>} }</p><p>3- Define your function that uses callback like</p><pre><strong>public static void </strong>postData(String targetUrl, HashMap&lt;String, String&gt; paramsPost, <strong>final </strong>MyCallbackInterface callback) {<br>..<strong>new </strong>HttpRequest() {<br>    @Override<br>    <strong>public void </strong>onResponse(String response) {<br>        <strong>super</strong>.onResponse(response);</pre><pre>callback(response); } <br>.....</pre><pre>}</pre><p>So the data returns in response to post call will be sent to the callback and got parsed to json or processed in other ways. This is typical callback and it works. Dont try to make wrapper classes, no need for them. The suggestions and samples in stackoverflow are … mmm… overskilled?</p><p>You can of course use callback as closure like in Swift. You can skip step 2 to form a closure like this</p><pre>postData(&quot;https://mydomain&quot;, myHashmap, new MyCallbackInterface {<br><a href="http://twitter.com/Override">@Override</a><br>public void onDownloadFinished(String result) {<em>// … your code here. ie. handle the result like process the string result …</em>} }</pre><pre>});</pre><p>I would prefer step 2 as it is clearer to read and debug but it is not wrong to use closure format.</p><p>Why use callBack instead of listener? 2 reasons:</p><ol><li>Maintenance: The function to process data is independent to the module that produces data. ie. process data returned from a Rest call. This makes the code easy to read and clear logic.</li><li>Standard: It is typical async architect and structure. The code can be translated to other languages. Listener is Android only.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d2623181a7a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Android Bridge Popup]]></title>
            <link>https://mytee.medium.com/android-bridge-popup-554f8ef0364b?source=rss-50d37084b3ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/554f8ef0364b</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[bridge]]></category>
            <dc:creator><![CDATA[Michael Tran (mytee)]]></dc:creator>
            <pubDate>Mon, 23 Jul 2018 05:07:54 GMT</pubDate>
            <atom:updated>2019-12-16T00:56:14.671Z</atom:updated>
            <content:encoded><![CDATA[<p>Popup by Intent</p><p>Chapters: <a href="https://medium.com/@mytee/android-simple-webview-adf59703a2ba">webview</a>, <a href="https://medium.com/@mytee/android-bridge-js2java-7c0b62fe782">JS2Java </a>, <a href="https://medium.com/@mytee/android-bridge-java2js-10467426eeb5">Java2JS</a>, <a href="https://medium.com/@mytee/android-dialog-4018680827c4">Alert dialog</a>, Popup Screen.</p><p>Lets call a popup screen from JavaScript thru the Java Bridge class.</p><p>In the previous chapters, we have already seen how it works. The logic is simple: add one more function in the bridge object, then call it from Javascript; then listen to the return message.</p><p>The idea is using intent activity. Ref <a href="https://developer.android.com/reference/android/app/Activity"><strong>https://developer.android.com/reference/android/app/Activity</strong></a></p><p>The layout of popup screen can be either pure coded, or using res/layout with xml. We will try both. There will be two buttons on html, to call them in different format: with and without layout file.</p><p>We will add the code into the Bridge_protocol class.</p><p><em>// Show popup<br> @JavascriptInterface<br> public void showPopup(String Msg) {<br> Intent myIntent = new Intent(getApplicationContext(), Popup.class);<br> // startActivity(myIntent); //if no need return code <br> startActivityForResult(myIntent,100, null); // if required return value<br> }</em></p><p>The call startActivity(myIntent); is for the case you dont want to trap return value from the popup screen such as aboutbox, contact info or the like.</p><p>The way to trap the return is adding the function into the bridge class like this</p><p><em>// to get return from popup screen<br> @Override<br> protected void onActivityResult(int requestCode, int resultCode, Intent data) { System.out.println(“onActivityResult: “ + resultCode);<br> if (requestCode == 100) { // it is my code predefined as 100<br> if (resultCode == RESULT_OK) { System.out.println(“result ok onActivityResult: “ + resultCode);<br> } else {System.out.println(“result cancel onActivityResult: canceled”); } } }</em></p><p>There are two popup classes. You will find the one that uses layout xml file is very simple because most of the elements are dome via interface builder. The code to bind the class to the layout is to call setContentView() in popupScreen class.</p><p><em>@Override<br> public void onCreate(Bundle savedInstanceState) {<br> super.onCreate(savedInstanceState);<br> setContentView(R.layout.forecast); // using layout here <br> }</em></p><p>You can also close the screen by</p><p><em>this.finish(); // or onBackPressed();</em></p><p>By experiment, I found the onDestroy() called by both of them. Therefore, any can do.</p><p>The sample project is here <a href="https://github.com/myteeNatanwit/AndroidBridgePopup">https://github.com/myteeNatanwit/AndroidBridgePopup</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=554f8ef0364b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Talented Coder or Software Engineer]]></title>
            <link>https://mytee.medium.com/talented-coder-or-software-engineer-96a23c28fd4a?source=rss-50d37084b3ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/96a23c28fd4a</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[coding-style]]></category>
            <dc:creator><![CDATA[Michael Tran (mytee)]]></dc:creator>
            <pubDate>Mon, 07 May 2018 05:39:23 GMT</pubDate>
            <atom:updated>2018-10-09T11:19:57.325Z</atom:updated>
            <content:encoded><![CDATA[<p>Genius vs standard</p><p>Ask yourself a question: “<strong><em>Why all apps from Apple are very common, no fancy at all?</em></strong>”</p><p>Sometimes, you find your job application hit a coding test. From the look of the job spec and code test, you can tell who proposed the job spec and what he looks for.</p><p>If the job spec asks for multi skills, multi roles, multi products and the code test is quite challenging, required high skills of coding. You can be certain that the one who listed the job is a coder and he definitely is looking for a coder. Remember the issues we discussed in “Rock climbing or high way” article? We know coder is always seeing coder, in his eyes only coder existed. He doesnt appreciate the engineers and their works to his eyes are always overdone. He values them with his vision that limited with his observation, mentality and experience. With hammer and nails he can put two pieces of wood together in 5 minutes, why need some metal frames that take extra work?</p><p>Have you worked out the metaphor yet?</p><h3>The Metaphor</h3><p>coder = handyman.</p><p>talented coder = very skillful handyman.</p><h3>The facts</h3><p>Engineer can do some handyman work, not the same way, and not as fast as a skillful handyman can.</p><p>Handyman -regardless of skills- cannot do engineer work as the background training and qualification are different.</p><p>Handyman mentality, logic and solution are driven by personal experience.</p><p>Engineer solution is based on standard, planned methodology.</p><p>Coder looks at doing the product .</p><p>Engineer looks at the way to do the product.</p><p><strong>Coder does thing that can be changed best by himself.</strong></p><p><strong>Engineer does thing in the way that other engineers can understand and change it themselves.</strong></p><p>In short, handyman is more productive, but his work is best maintained by himself.</p><h3>The story</h3><p>Say, you had a skillful coder in place, and he started working on the coding. Very impressed, you see the app showing, screen after screens; feature after features. The app released after 1, 2 years coding. You are happy. Happy? Wait! Lets look at this story again.</p><p>You know how coder is coding? you know how he codes like? any documentation? any comment? any standard applied?</p><p>No! <strong>All coders learn by experience</strong>. They spent countless days and nights in coding, they love coding, experiments, new coding techniques. The applications and the fancy result are their passion. In the same way, coding standard, readiness, maintenance are not the main focus. If you ask, they will say yes, but they dont pay great attention in them. Why? because it is coder mentality. They only get excited at the skills and end result.</p><p>If you looked at this coder codes, you will find a whole spaghetti. Not that he doesnt want to do it in the right way, he cannot with his mentality driven. You force him, he can do it in few days, but when the pressure come up, he will go back to his spaghetti coding style. That is coder’s nature. You cannot make a handyman become an engineer.</p><p>What if he walked away after 2 months? not too bad! you could get a new staff in, takes say 2, 3 weeks learning -the system, the application, the existing work- and continue. You feel sad a bit for that 3 weeks time as the new developer has not been productive. In a way, you paid 3 weeks for nothing.</p><p>What if he walked away after 11 months? Now it is bad. The new staff will take 4, 5 weeks to be somewhat productive. Some codes are too confused for him, some are spaghetti work if the previous developer didnt follow software standard.</p><p>What if he walked away after the product released? bad news! You will need to do it from beginning.</p><p>Watch out! If you still not see the picture, you might as well get in place another skillful coder. The story will be beginning with the same sad ending. Someones can do the same mistake many times.</p><h3>The risk</h3><p>You will find coders with programming short courses or self learning are often very talented, but their coding style is not standard. The best people who can make the change in their code are themselves. No proper comment, no software engineering practice, no proper document. <strong>They can be very productive but also destructive in the same time</strong>.</p><p>Why? This brings to the company the biggest risk: <strong>Technical Staff dependency</strong>.</p><p>1- After they left. It takes ages for someone who can step in and continue the work properly.</p><p>2- The damage of spaghetti code will make the product very buggy. By fixing a bug in one place will produce new bugs in other places. Some of them are very mysterious.</p><p>3- Project planing is inaccurate. You cannot do proper plan with ambiguous bugs or issues. You cannot do estimation on something uncertain. We call it “<em> ghosts in the shell</em>” for the mysteriously pop in and pop out bugs. They will show up in a number of Springs and/or persistently in backlog.</p><h3>The team</h3><p>How the handyman works in your team when you are team leader?</p><p>Scene 1:</p><p>If he is not very skillful, he can go with the team, in a passive way, you give him a task, he did it well only his coding style is spaghetti. Can you work with it? yes, if you give him a standalone component, a blackbox. You dont have to worry about his mess. You know one thing for sure it will be buggy. You expect that he will be mad with his own work and will do it again from beginning one day. I saw this many times.</p><p>Scene 2:</p><p>He is very skillful, your young team members will realise it. They even compare your coding skills with his and easy worked out you are not as good as that coder. That genius eventually implied that you are an idiot and he is much smarter than you are. Can you work with it? Yes, give him stand alone projects that wont affect main project like admin tools, landing page, logs analyzing and alert... those require high level of coding and low maintenance.</p><h3>The boss</h3><p>What if the coder is your boss?</p><p>It is very unlikely, because the coders only look for coders. They dont want engineer, they dont like engineer. Not that they cannot work with engineers, but deep inside they know they are not in the same class, and they hate it. As we discussed in “Rock climbing or high way”, you dont want to be there in the first choice.</p><p>Someones are born to marry. The salesman boss will marry the skillful coder. The salesman boss says: “I dont care how you do it, but I want the product now”.</p><p>The coder says: “It is done, I released it”.</p><p><strong>Loop here</strong></p><p><em>repeat until they rebuild it from scratch {</em></p><p><em>The boss says: “There are bugs”.</em></p><p><em>The coder says: “I fixed it, tested, released it”.</em></p><p><em>The boss says: “New feature, do it now”.</em></p><p><em>The coder says: “I did it, tested, released it”.</em></p><p><em>}</em></p><h3>The coder life circle</h3><p>How you become a coder? Some coders come from programming short courses or Tafe training, where they get training to gain the skills. As you recalled, coders only want to improve the skills. After the basic knowledge, they jump into coding days and nights and then become expert in coding.</p><p>Can people from formal training in software engineering become coder? yes! definitely. In four year of software engineer course in uni, you can find students who are very high mark in coding, programming subjects and low mark in analysis, design, architect. Those are coder tendency. When they finished uni, joined a company, leaded by coders, they will drop everything they learned in uni and become coder.</p><p>Few of them eventually found the product is not ideal and recalled something about the software engineering subjects they have learned, then more or less correct themselves. This however is quite rare. Dropping standard is much easier than establishing standard.</p><p>Can a Software Engineer also be good coding even not to be a handyman? Yes. In many cases, the team lead must have good coding skill, team members also will develop coding skill. However, with the intention of the uni training, the team member must stand on the engineering ground to build up the coding skills. They must grow in healthy balance. They must do thing in the right way.</p><p>I can suggest a typical IOS engineer who is also a genius in coding. Tsutsumi Shuichi, <a href="https://medium.com/@shu223">https://medium.com/@shu223</a> . Lets look at his code in <a href="http://github.com/shu223?source=user_profile----------------------------">http://github.com/shu223</a>. Very deep knowledge in IOS at kernel level and very standard way of coding, he did thing in the right way. Look at his work, you will see that you dont have to be fancy to be a genius.</p><h3>Why software engineer?</h3><p>Ask yourself a question: “<strong><em>Why all apps from Apple are very common, no fancy at all?</em></strong>” Because they know the problem of fancy genius. They lost heap of money on that genius risk. They keep emphasize the standard in every single seminar and workshop. Even Apple keep asking for standard and employing graduated uni software engineers for the standard, why dont we?</p><p>Things in common and great about the uni graduated are: They are greatly common! The universities produce mass production for the engineers. They look the same, they learn the same subjects, they get same training, they speak same languages, they write same languages. What they got from uni is international standard. They understand each others with same methodologies, technologies, UML, DBMS, scheme, charts…</p><p>The most important fact is they can replace each others. When you need new staff, the software engineer can be real quick become productive, if the one left has followed standard. When you want more staff, the new guy can easy trained because the work are following the standard, which is what he already trained in uni.</p><p>In short, they are like the caps for the milk bottles. They can fit on any bottle with standard size. They also know to follow the standard software engineering methodologies which ensure you work will be in safe side.</p><h3>Do we need genius coder?</h3><p>For quick and fancy product, yes. They can do thing <em>use once and thru away products</em> wonderfully.</p><p>For thing you dont want maintenance, then the coders do best.</p><p>For version 1.0, when you dont have your team, then best to get a coder to do it as contractor. You will build a team and do version 2 from beginning. It is not worth debug and maintain the coder work.</p><p>Can we use the skillful coder’s work? Yes. I often download, learn some excellent work from the experts via Github. With high respect, I change a bit — just a bit- to be sure it still works, and learn some advance coding techniques from it. Those that require more than 100 lines of code changing. I stay away, simply because these genius work are too … genius!?.</p><p>Do I want to improve my coding skills? Yes, I do. I read book, many books. I attend seminars, workshops from Apple. I paid for my teams to go there. I also download the sample codes from genius and learned a lot from them. I never stop leaning. However, I do the genius coding … at home.</p><p>Guys! Do it at home. Do the fancy apps to sell under your name. Dont apply the fancy technique to company commercial apps. Dont bring you genius things to work. The company and your team will suffer non-standard effect.</p><p>No fancy, the app still works perfectly matching the specs. With fancy, it comes with bugs. Why should you do it? Why you want to bring extra debug work for your team?</p><p>In the old days, people would be proud to have the genius coders in house. Since nobody like to pay twice for the same product. The companies eventually found that the coder work always lead to rebuilding the product from scratch.</p><p>There are significantly differences in the job advertisement and interview when people look for software engineer or coder. The first one is for qualification, experience and skills. The second one is for the skills.</p><h3>Dont we need the genius?</h3><p>No. We dont want genius coder when we want to build a team of software engineers to do thing in the right way. Remember the fact: <strong>Only genius coder can edit his own code effectively</strong>. The genius coders always do thing in their way which is always the hard way. No. You want the products extendable and maintainable.</p><p><em>The genius coder: I can do it from A to Z in short time.</em></p><p><em>The software engineer: I can build many reusable components that form many products. We do once, reuse in many products.</em></p><p><em>The genius: My coding skills are great.</em></p><p><em>The engineer: The coding guideline is the coding must be readable and maintainable.</em></p><p><em>The genius: My code is very talented. People look at it and impress with the impact. One line can do many things.</em></p><p><em>The engineer: Every file must be less than 400 lines of code for easy understanding. Every module must have comment in the standard. Express your logic in clear statement. If 1 line can do 10 things, write 10 lines to do 10 things to make them readable.</em></p><p><em>The genius: My code is wonderful, real fast in performance, using low level coding.</em></p><p><em>The engineer: Remember you write the code for someone to debug. Stay with high level and clear coding, no fancy.</em></p><p>As you can see, the mentality of both sides are totally different. The articles “D<a href="https://medium.com/@mytee/do-the-right-way-with-component-b1cb72247993">o the right way with component</a>” and “<a href="https://medium.com/@mytee/do-the-right-way-with-team-work-a277026c8552">Do the right way with teamwork</a>” emphasize the advantage of team work and components.</p><p>The question we need to ask is “<em>What do you want to build? A tree house or a house? a log or a building?”</em></p><p>According on your answer, you will need engineer or handyman.</p><p>Are you a coder? then go for coder, because the engineer wont agree with you if he is a pro.</p><p>If you are an engineer, then you can decide, based on the development phase of your project. You need a team of engineers to build the project in proper way, or you want something quick with handyman skills and build it again in future.</p><p>Further question, do you want <strong><em>a team of developers, or a group of individual coders</em></strong>? They are entirely different.</p><p>…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=96a23c28fd4a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Do the right way with Team work]]></title>
            <link>https://mytee.medium.com/do-the-right-way-with-team-work-a277026c8552?source=rss-50d37084b3ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/a277026c8552</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[teamwork]]></category>
            <dc:creator><![CDATA[Michael Tran (mytee)]]></dc:creator>
            <pubDate>Sun, 29 Apr 2018 11:18:55 GMT</pubDate>
            <atom:updated>2019-04-01T02:23:40.457Z</atom:updated>
            <content:encoded><![CDATA[<p>Mobile App and Team work with component development</p><p>You can do the whole lot from server end, database, middleware to frontend. However, you cannot handle the workload of the team. What if you face 4,5 systems same time? What if each system requires 20, 30 screens or components? What if you find many components can be used across the apps?</p><h3>Team work</h3><p><strong><em>The idea is the whole team will work together to analyse the many apps to determine the components that will be self-assigned to the team members.</em></strong></p><p>To illustrate the idea, we take a web site as an example.</p><p>To avoid the infliction between developers, you will need to build the screen independent to others, so that developers can work in parallel.</p><p>Often, you will make screen and its function in folder. For examples, under folder profile you would have</p><p><em>js/profile.js</em></p><p><em>css/profile.css</em></p><p><em>images/pic1.png …</em></p><p><em>profile.html // the profile screen itself to be called by the parent</em></p><p><em>index.html //the screen to call up the profile for local development</em></p><p><em>…</em></p><p>The parent index.html will most likely dynamic load the profile with $(“container”).load(“profile/profile.html #subContainer”), not to preload to save memory and loading time for the main website.</p><p>By doing this, you are doing component development for your application. Please refer to the previous article “<a href="https://medium.com/@mytee/do-the-right-way-with-component-b1cb72247993">Do the right way with Component</a>”. The work looks like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5qi4FVHfZ-5wPR7gzq8Rsg.png" /><figcaption>staff on based component</figcaption></figure><h3>Mobile App</h3><p>You dont do 30 screen app too often. However, when people want to change their web app to native, you might come across something like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xm57oSXq7tdgJln3JDLNRQ.png" /></figure><p>It is not a simple work, as the logic of web app is not quite the same of native app. In native app, we use the IOS framework and inherited down the classes for customizing them. Therefore, the wireframe products on market, stick with Apple look and feel, while those converted from Web apps tend not to be in that trending.</p><p>In certain limit, it is acceptable for custom classes approach since it might make your app standing out, just that the fancy apps will have more chance to get rejected by AppStore. The mystery in AppStore was discussed in “<a href="https://medium.com/@mytee/undocumented-app-store-7ddd28a8e4a6">Undocumented Appstore</a>”.</p><p>The wireframe of native app could look like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*M0RjBs6oKxNiWTp8xtZYRg.png" /></figure><p>The way we work with mobile app is very much the same of above with team work. We do component as discussed in previous article “<a href="https://medium.com/@mytee/do-the-right-way-with-component-b1cb72247993">Do the right way with Component</a>”. Very much the same, we put all files belong to the component under a folder. Under the folder profile, there will be files like this</p><p><em>1- ProfileViewController.swift // control and model</em></p><p><em>2- ProfileViewController.storyboard // view</em></p><p><em>3- profileViewControllerPickerExt.swift // for picker extension</em></p><p><em>4- …</em></p><p>The local project that direct accesses the profile folder is profileUI.xcodeproj. it also has it own viewController and storyboard. The main storyboard is an empty view with one button to call up the profile. There is reason for this structure, as all the development, debug, changes are in this local project.</p><p>The parent project will have <strong>read only access to the profile folder and call it as a blackbox</strong>. The concept of “<a href="https://medium.com/@mytee/do-the-right-way-with-swift-797b54d265c2">blackbox</a>” has been discussed earlier. The parent project wont make any direct change to the profile component. However, any further changes in the profile sub project will automatically reflect to all the apps that use the profile component.</p><h3>Component Structure</h3><p>You will find all components are structured in the same way. A project that has an one button screen, that calls the component in its folder, that has the swift file for the ViewController and storyboard file for the view.</p><p>An AboutBox based component file structure looks like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*JK_BMLfl5aGFNdpsmuIVcw.png" /></figure><p>Why? With this structure, the development will have many advantages:</p><p>1- Staff exchange: Developers in the team will easy exchange or share the work. One is not available, other can just take over.</p><p>2- No staff dependency: The code and development are transparent to the team member. Everyone knows and can help others.</p><p>3- Time and cost saving: There wont be any delay with long learning curve for changing and training staff.</p><p>4- Standard coding style: The codes to access the components are in the root module. Coder will use the same function to call the component. No new code, no new bugs.</p><p>Look at the sample code for components in Github. The <a href="https://github.com/myteeNatanwit/aboutBox">AboutBox</a> is to show file structure and simplest call without param passing and return. The <a href="https://github.com/myteeNatanwit/getPin">getPin</a> is to show the use of protocol and delegate to return data. They are straight forward and simple to share across the team.</p><p>…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a277026c8552" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Do the right way with Component]]></title>
            <link>https://mytee.medium.com/do-the-right-way-with-component-b1cb72247993?source=rss-50d37084b3ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1cb72247993</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[maturity-model]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Michael Tran (mytee)]]></dc:creator>
            <pubDate>Thu, 26 Apr 2018 10:08:20 GMT</pubDate>
            <atom:updated>2018-07-24T23:07:14.999Z</atom:updated>
            <content:encoded><![CDATA[<p>IOS Component based development in “<strong><em>defined</em></strong>” level</p><p>Can you release high quality major project in 3 months?</p><p>Humphrey in his book <em>Managing the Software Process</em> 1989 expressed the maturity level of software development. <a href="https://en.wikipedia.org/wiki/Capability_Maturity_Model">https://en.wikipedia.org/wiki/Capability_Maturity_Model</a></p><p>“<em> the levels are defined as:</em></p><p><em>Initial: The software process is characterized as ad hoc, and occasionally even chaotic…</em></p><p><em>Repeatable: The necessary process discipline is in place to repeat earlier successes on projects with similar applications…</em></p><p><em>Defined: The software process for both management and engineering (development) activities is documented, standardized and integrated into a common software process set for the organization…</em></p><p><em>Managed: Detailed measures of the software process and product quality are collected. …</em></p><p><em>Optimizing: Continuous process improvement is enabled by quantitative feedback from the process and from piloting innovative ideas and technologies,...”</em></p><p>Man! English guy has the way to make thing so ambiguous. Put it in very simple way: If a coder writes the code from A to Z for the app, then it is “<strong><em>initial</em></strong>” level. If he then did a lot of code libraries, and re-use them instead of re-write them, then he is in “<strong><em>Repeatable</em></strong>” level. You can take the MS studio, Xcode IDE, and Android Studio are in this level, as most of the components are integrated from within the IDE. Many classes are pre-defined and coders just use them, <strong><em>repeat </em></strong>the same steps to use them, not to re-write them.</p><p>The difference from the previous level is the re-useable classes, which are well tested. Therefore no need to re-code them anymore. The application is built faster, fewer bug in this level.</p><p>When people talk about the application by “<strong><em>defining</em></strong>” the components that form the application, then it is “<strong><em>defined</em></strong>” level. The work is done at the components level; bugs are localized and development time is short. We will focus only the “defined” level and its corespondent development.</p><p>At defined level, the development key is <strong>not to develop the application, but to develop the components that form the application.</strong></p><h3>Component vs component</h3><p>Since it is rather confusing between interactive or plug in component in IDE and blackbox or base component in development, it is better to make it with examples.</p><p>Say in Xcode, you can drop a TableView into your ViewController. The TableView is reusable component of the Xcode IDE. You can use it in virtual environment or programmable. This is a typical interactive component, not a blackbox component.</p><p>Why? because it is not self complete. It is used to carry data. Without the coding and data from the controller part. It is blank. Also, at later stage, you can see clearer that a tableview can not be used to “define” a system. It is only a integrative component.</p><h3>Define an application</h3><p>Lets practice a ”<strong><em>define</em></strong>” on an application. What are the components required to form a Spotify or a Tumbler?</p><p>We will need</p><p>1- A landing screen. It can have a videoplayer part, login and register buttons. We can change the video and reuse this component in other application, yes? yes!</p><p>2- A login screen. It must have username and password. This can be used in other apps, yes? ok, it is another component.</p><p>3- A register screen. It has email, password and submit button. Yes?</p><p>4- A reset password, yes?</p><p>5- A profile screen. It is sure a component.</p><p>7- An About box? yes, it is.</p><p>8- A card form to list the posts from the others and yourself?</p><p>9- A post form for user to post?</p><p>10- …</p><p>You can see the based components yet? They form the app. They “<strong><em>define</em></strong>” the app. They work like the Lego. Putting the lego pieces together to form a structure. The lego structure is “<strong><em>defined</em></strong>” by the lego components.</p><p>This maturity approach practically saves people huge time and money. Have you ever seen three developers doing 3 separate login screens for 3 applications that login to the same server? What they did is the “<strong><em>initial</em></strong>” stage, which is understandable in the 90th, when we still work with Win95 and the dinosaurs were running in the park.</p><h3>Stone age?</h3><p>What? I am serious. Not kidding, even it is in 2018, I saw they code from A to Z for the apps. I am assure you. Now, even in this century, there are many software companies with popular products are still in stone age for their software development. They did the right thing with their products but they did them in the wrong way. Oh, you can guess. They spent huge money and time to … debug and finally re-do the whole application over and over again… still in wrong way!.</p><p>You can see what my team and I can do in 3 months, they do in 2 years. It is still not the end of it. After those 2 years, they get 3rd party to do a new one for another 12 months, then they not happy, get another new development for another 2 years. Man! I have seen this sad story many times in many places. They keep doing thing in the wrong way!</p><p>How could it happen? It is the maturity of the development environment. The project owner has no glue of the software development maturity. The coders — not software engineers- only know to code. They keep doing wrong way over and over again. Costs a lot of time and money. Think about someone stays 10 years old for … 30 years!.</p><h3>Component development</h3><p>Again, my team and I have done many major projects in average 3 months each.</p><p>How? the component based development is the key. We developed many blackbox components: login, register, reset, profile, setting, PIN, barcode reader, QR code reader, VR model, posting, sharing, table based listing, card based listing, pay-getway, RFC component, sockets realtime, Rest components… on both client and server sides. Some components we did a few for the choices. The idea is my team built the new apps by reusing the components. We coded only 5–10% max of the app. We do major applications in 3 months average.</p><p>You will find later in this series some tutor for components that to present the idea of development based component. <strong>Not to develop the application, but to develop the components that form the application. It is the difference</strong>.</p><h3>The main project is empty cell</h3><p>The application by itself will be more or less an empty cell. It looks like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zehCDhG8vBwaruzv-HFp5g.png" /><figcaption>Main project is an empty cell</figcaption></figure><p>The components are the sub projects, that form the main project or application.</p><h3>Sub-project component</h3><p>Why we say sub-project? because the component itself is another empty cell for it child projects those form this bigger size sub-project. It looks like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SiFzeAVxerUdFsEJWaAsJg.png" /><figcaption>Sub project can be empty cell</figcaption></figure><p>Can we do a few sample sub-project components that you can refer to? sure. You will see the <strong><em>GitHub</em></strong> for the demo of the component. The <a href="https://github.com/myteeNatanwit/aboutBox">AboutBox</a> is to show file structure and simplest call without param passing and return. The <a href="https://github.com/myteeNatanwit/getPin">getPin</a> is to show the use of delegate to send data to parent. They are straight forward and simple.</p><h3>Child project component</h3><p>The idea for the child project component is an simple UI screen with a single button, that to call the component. It acts like a demo, to bring up the component as a blackbox module. The module or blackbox component can be in any language, and any UI form, as long as they serve the purpose of a complete functional module. The structure is like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*GENvy14hyDEx9tt1dYcTTA.png" /><figcaption>child module</figcaption></figure><p>You might see by now the development for this level is not for the application project anymore. <strong>It is the development of the child components that form the based components, that in turn form the application.</strong></p><p>Since the components are independents to the application. They are reusable for many applications those in the definition require them.</p><p>As referred to “<a href="https://medium.com/@mytee/do-the-right-way-with-storyboard-67678b535f85">Do the right way with Storyboard</a>” article, the component will has its own folder, storyboard, controller and extension. For examples, under the folder GetPinViewController, there would be</p><p>1- GetPinViewController.swift for the class model and control.</p><p>2- GetPinViewController.storyboard for the class UI or view.</p><p>3- GetPinViewControllerTableExt.swift // for the table delegate if using tableView.</p><p>To plug this component into the parent project, you <strong>drag and drop the GetPinViewController folder into the parent project in Xcode. Dont copy it</strong>. The correct setting is like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/732/1*StF19AYZT8NKDyf9rOAc_g.png" /></figure><p>Why? the GetPinViewController component is belonging to the child project GetPinViewController. <strong>The development of this component is for this project only</strong>.<strong> The parent project is only use it as using a blackbox</strong>. Therefore, if you made copy, then you would have shifted the ownership and broken the blackbox development circle. We have discussed this issue in previous article “<a href="https://medium.com/@mytee/do-the-right-way-with-swift-797b54d265c2">Do the right way with Swift</a>”.</p><h3>Component Structure</h3><p>You will find all components are structured in the same way. A project that has an one button screen, that calls the component in its folder, that has the swift file for the ViewController and storyboard file for the view.</p><p>An AboutBox based component file structure looks like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/391/1*JK_BMLfl5aGFNdpsmuIVcw.png" /></figure><p>In Xcode it looks like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*A76IsXpizH5ZTOXaeDc8Zg.png" /></figure><p>In main.storyboard of the component project, it looks like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/483/1*Yv2byBIpKF3Dimiuw3r4Qg.png" /></figure><p>The simple version to call the AboutViewController is like this</p><p><em>func loadViewControllers(_ named: String) {<br> let storyboard = UIStoryboard.init(name: named, bundle: nil)<br> let targetViewController = storyboard.instantiateViewController(withIdentifier: named ) self.navigationController?.pushViewController(targetViewController, animated: true)<br> }</em></p><p>The code bind the button Click action looks like this</p><p><em>@IBAction func btnClk(_ sender: Any) {<br> loadViewControllers(“AboutViewController”) }</em></p><p>Note that <strong>the AboutViewController has it own storyboard</strong>, not in main.storyboard and linked with a segue. We use this structure always for all component projects.</p><p>Why? With this structure, the development will have many advantages:</p><p>1- Staff exchange: Developers in the team will easy exchange or share to work. One is not available, other can just take over.</p><p>2- No staff dependency: The code and development are transparent to the team member. Everyone knows and can help others.</p><p>3- Time and cost saving: There wont be any delay with long learning curve for changing and training staff.</p><p>4- Standard coding style: The code to access the components are in the root module. Coder will use the same function to call the component. No new code, no new bugs.</p><p>5- Team work enable: You can do team work with mobile app via component development. We have discussed about it in “<a href="https://medium.com/@mytee/do-the-right-way-with-team-work-a277026c8552">Do the right way with Teamwork</a>”.</p><h3>Using Plugin</h3><p>Most people do the child components from scratch. Some use plug in. Often, the plug in approach is faster, but need more resource for testing before putting in production. We will try to do a tutor on plug in approach shortly. Lets try this <strong><em>link</em></strong>, when it is enable.</p><p>…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1cb72247993" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Do the right way with Storyboard]]></title>
            <link>https://mytee.medium.com/do-the-right-way-with-storyboard-67678b535f85?source=rss-50d37084b3ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/67678b535f85</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[storyboard]]></category>
            <category><![CDATA[coding-style]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Michael Tran (mytee)]]></dc:creator>
            <pubDate>Sun, 22 Apr 2018 05:22:18 GMT</pubDate>
            <atom:updated>2018-08-27T07:08:04.459Z</atom:updated>
            <content:encoded><![CDATA[<p>Slim vs Fat: Multi storyboard</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*TG7ryntlD9NrT1xMquydug.png" /></figure><p>Q: What is wrong with this storyboard? A: omg! it is a bad idea.</p><p>I have seen a storyboard with more than 25 view controllers, in each there are many subviews. It is real bad idea.</p><p><strong>People confused screen wireframe design with Xcode storyboard. It is never meant to be the same.</strong></p><p>Have you seen things like these?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*5zS77hahHT0t3Wtphe60Cg.png" /><figcaption>Storyboard mess 1</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*bfo2GczXEwsvlQprM_5FVA.png" /><figcaption>Storyboard mess 2</figcaption></figure><p>Dont do storyboard like this</p><p>Why? since storyboard is a big XML, then</p><p>1- In design time, loading, parsing, drawing are slow; memory taken for this is huge; the change on screen will be very slow to update. Nobody would fall in love with the spinning cursor.</p><p>2- In the development time, going thru this mess will drive you nut, and will drive someone crazy alter you left. Have you tried to find a bug for double binding of the properties? If you are lucky enough, it might take you a few hours, or a few days otherwise. With the mess like the above pictures, you sure cannot be lucky.</p><p>3- In the run time, your app loads this huge resource file will take long time. Remember Apple rule: they reject the app takes more than 4 secs loading. You can read further in “<a href="https://medium.com/@mytee/undocumented-app-store-7ddd28a8e4a6">Undocumented Appstore</a>”. Even if you are lucky enough to pass it, your users will feel that your app is slow loading comparing to others.</p><p>Do like this</p><p>Making storyboard for each individual view controller. We have discussed this approach in previous article “<a href="https://medium.com/@mytee/do-the-right-way-with-swift-part-2-6061d0e8c403">do the right thing with Swift</a>”. The idea is</p><p>1- Make the viewcontroller class into a component. It will have the swift file for the controller class and the storyboard file for the UI of the class. For examples, under the folder feedback, there are 2 files</p><ul><li>feedbackView.swift <em>// model and controller of the feedback class</em></li><li>feedbackView.storyboard <em>// the UI or view of the class</em></li></ul><p>2- Programmable load the controller as demand, not to pre-load as it is in the fatty storyboard. The code can be like this</p><p><strong><em>func loadViewControllers(_ named: String) {<br> let storyboard = UIStoryboard.init(name: named, bundle: nil)<br> let targetViewController = storyboard.instantiateViewController(withIdentifier: named ) <br> self.navigationController?.pushViewController(targetViewController, animated: true)<br> }</em></strong></p><p>to load the feedback component, you can do like this</p><p><strong><em>loadViewController(“feedbackView”);</em></strong></p><p>Why? Slim vs fat is the answer.</p><p>1- In design time, Xcode loads a slim storyboard no problem.</p><p>2- In develop time, you can easy manage all fields and theirs properties with slim storyboard.</p><p>3- The compiler will compile the storyboard in separate resource files. In run time, it loads only the main slim resource file, not the rest. You only call them as demand.</p><p>4- In debug time, you know exactly where the bug is when it crashes within a component. This is very important that you should follow this practice. Debugging is the most cost and time wasted especially when people do thing in the wrong way.</p><p>You might find some sample codes in github with a single storyboard with multi viewControllers. it works fine, like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/812/1*1-vAw5ItRnkuAtnq1gVcTQ.png" /><figcaption>&lt; 12 = acceptable</figcaption></figure><p>If my student submits the assignment with a storyboard like this, I will still pass that assignment, but with a B-, for the fault of taking storyboard for a wireframe design.</p><p>In a few workshops from Apple, my team and I attended, they suggest an app with max 12 static screens is good enough. Popup, picker, dialog dont count. This implies that a storyboard with less than 12 viewcontrollers is considered as healthy, not fat not slim.</p><p>However, as soon as you starting to do <a href="https://medium.com/@mytee/do-the-right-way-with-component-b1cb72247993">component development</a>, you will definitely stay with slim storyboard for its superiors.</p><h3>Hardcode the view?</h3><p>Man! Dont do that. It is the approach people did for last century. It is hard to figure out your screen looks like with hard code. Other members of your team will cry. It is not maintainable way. That is why everyone uses InterfaceBuilder. We must use it in the right way, that is all.</p><p>The article of component development is <a href="https://medium.com/@mytee/do-the-right-way-with-component-b1cb72247993">here</a>.</p><p>…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=67678b535f85" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Do the right way with Swift part 2]]></title>
            <link>https://mytee.medium.com/do-the-right-way-with-swift-part-2-6061d0e8c403?source=rss-50d37084b3ca------2</link>
            <guid isPermaLink="false">https://medium.com/p/6061d0e8c403</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[standards]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Michael Tran (mytee)]]></dc:creator>
            <pubDate>Sat, 21 Apr 2018 02:58:20 GMT</pubDate>
            <atom:updated>2021-04-12T04:53:15.312Z</atom:updated>
            <content:encoded><![CDATA[<p>Dummy screen, Comments, templates, naming, static Table…</p><p><a href="https://medium.com/@mytee/do-the-right-way-with-swift-797b54d265c2">The previous part is here</a></p><h3>Using dummy data</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*qrRdBiG7PO3dA8zmN1qKZA.png" /><figcaption>FB dummy</figcaption></figure><p>You might notice in slow connection, your facebook app screen is filled with the dummy like the above pic. It looks weird, but less irritating than the spinning loading sign. Tumblr app, store and load your last cards -stored in local storage -. This is much smarter than the weird screen above.</p><p>Why? in lazy cancer syndrome, people can do thing like this</p><p><em>func getUserData( callback: @escaping (_ result: String) -&gt; ()) {</em></p><p><em>let myUrl = URL(string: “https://www.google.com”);<br>var request = URLRequest(url: myUrl!)<br>let session = URLSession.shared;<br> request.httpMethod = “GET”<br> request.addValue(“application/json”, forHTTPHeaderField: “Content-Type”)<br> request.addValue(“application/json”, forHTTPHeaderField: “Accept”)<br> request.httpBody = jsonData</em></p><p><em>DispatchQueue.global().async() {<br> let task = session.dataTask(with: request) { data, response, error in<br> guard let result = data, error == nil else {<br> print(“\(error?.localizedDescription ?? “Unknown error”)”); return; }<br> if let httpStatus = response as? HTTPURLResponse, httpStatus.statusCode != 200 {<br> print(“statusCode should be 200, but is \(httpStatus.statusCode)”)<br> print(“response = \(response)”); }<br> let responseString = String(data: result, encoding: .utf8)<br> // print(“responseString = \(responseString)”)</em></p><p>DispatchQueue.main.async {<br><em>callback(responseString!) // update data here</em><br> }<em><br> } }<br> task.resume(); }</em></p><p><em>getUserData { text in<br> do { updateData() … }catch {…}}</em></p><p>You will find this works perfectly if 1-connection is fast. 2-data is small. Any of the above conditions doesnt match, then you got a blank screen for a while. A sinning cursor helps, but it is a wrong way to do.</p><p>Dont do like this approach</p><p>1-showing loading cursor.</p><p>2-load data from server.</p><p>3-display data only when data downloaded and processed.</p><p>4-hide loading cursor.</p><p>You know why. You will keep looking at the loading cursor for a while.</p><p>Do like this</p><p>1-showing loading cursor.</p><p>2-background loading data from server with dispatchQuere. ref here <a href="https://developer.apple.com/documentation/dispatch/dispatchqueue"><em>https://developer.apple.com/documentation/dispatch/dispatchqueue</em></a>. In simplest way, the code is like this</p><p><em>DispatchQueue.global(qos: .background).async {<br> // do your job here</em></p><p><em>DispatchQueue.main.async {<br> // update ui here<br> }<br>}</em></p><p>This will do the loading in the background, and then update the UI when the data is ready.</p><p>3-foreground loading dummy screen, with either default -like FB- or last saved data — like Tumblr -.</p><p>4-hide loading cursor.</p><p>There is another issue here. Have you noticed, tumblr only send 10 posts per query? it is server side, however, this approach helps in case you deal with graphic files. From client side, knowing the buffer per query, you will keep track of data for appending to your array.</p><h3>Dont use Generic function</h3><p>Why people want to use generic? only when they believe the same function can be used in various cases. Question is: Would you be able to solve the problem without using generic? Yes. You would.</p><p>Look at the code after 6 months. You will wonder why you did that way and what you meant when you did this way. The generic function will take you hours to figure out why you did it and will take someone else days to figure out how to rewrite it.</p><p>Stay close to type function. If it returns an Integer, let it be an Integer. If the param type is a String, pass in it a String. Dont make it Any or AnyClass then type casting it. The bug for this mess is classified as misery because you might find it if user happens to input something far too wrong from typecasting, or you never find it as you and your QA would never expect to pass to the param such thing.</p><h3>Dont pass more than 3 parameters in function</h3><h3>Use semi colon at end of statement for a good habit</h3><p>If you live with Swift only, then it might not be necessary. Often, people work in several languages Java for Android; JavaScript for Nodejs … The semi colon indicates clearly that you already end the statement. It works with all languages, including Swift even it is not strictly required.</p><h3>Use Comments</h3><p>We have to do comments for several vital reasons</p><p>1- for ourselves when we read the code a few months later.</p><p>2- for people, as our ethnic and professional. The one who change your codes when you left wont cry on your work.</p><p>3-for your employers. They need the document that we can do with the document generator. The tool will generate the document from your comments.</p><p>Dont do like this</p><p><em>//name</em></p><p><em>//purpose</em></p><p><em>//param</em></p><p><em>//output</em></p><p><em>//usage</em></p><p>why? ”//” is line comment, it is for variable and logic comment, used only for If Else, define variables …</p><p>Do like this</p><p><em>if (thisCondition &lt; thatCondition) {} // we use line comment here</em></p><p><em>let maxCount = 10 // line comment here</em></p><p>and, on top of the file</p><p><em>/* Name: GetPinViewController</em></p><p><em>*Purpose: validate the Pin and user input.</em></p><p><em>*Param: numeric string</em></p><p><em>*Output: True/false</em></p><p><em>*Usage: using weak var localData for Pin</em></p><p><em>*/</em></p><p>Also, on top of the func</p><p><em>/* Name: Alert</em></p><p><em>*Purpose: simple alert box.</em></p><p><em>*Param: title: string, message: string</em></p><p><em>*Output: none</em></p><p><em>*Usage: alert(“this is title”, “this is message”);</em></p><p><em>*/</em></p><p><strong><em>func Alert(_ title: String, _ message: String) {…}</em></strong></p><p>Note that the <strong>same template used for both header and the function</strong>.</p><p>Why? The module itself is called as a function in blackbox style. Furthermore, the document generator will do the layout of the whole structure. It shows from main/root to all modules and their internal functions in a clear diagram, if the comments are done properly. What? You dont know the document generator of PHP can do document for Swift?</p><h3>Using template panel</h3><p>In Xcode, you should use the template panel. It is the 2 curly brackets tab on the bottom right panel that looks like this {} as in the picture below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*67GIF0EwX1SYqoOQE0CCuw.png" /></figure><p>tab on it, you will see many code templates.</p><p>Do like this</p><p>Copy this comment into your editor, then drag and drop it into the template panel. It will create a comment template for you. You might like to use a short cut code. Next time, you just drag and drop this template from the panel back into the editor, to the top of the file and func. You just fill the spaces, save the typing.</p><p><em>/* Name:</em></p><p><em>*Purpose:</em></p><p><em>*Param:</em></p><p><em>*Output:</em></p><p><em>*Usage:</em></p><p><em>*/</em></p><p>Why? from observation for last … decade, coder is lazy to do the comment because of its bore some. Using the template is more or less help. In my practice, it is a must anyway.</p><h3>Using the right name for the module</h3><p>Say if you have a class name LoginViewController, then the file must be save with the same name of the class. The swift file LoginViewController is for the class LoginViewController. The storyboard of this view controller should name LoginViewController.storyboard as well. Also, the storyboard ID of the view will be LoginViewController.</p><p>In summary, you will find in the login module folder</p><ul><li>a swift file name LoginViewController.swift that is for the class LoginViewController</li><li>a storyboard file name LoginViewController.storyboard, in which the viewcontroller ID will be LoginViewController.</li></ul><p>Why? later in the code, anything refers to LoginViewController, you know the definition of this class is in the file LoginViewController.swift and the UI of it will be in LoginViewController.storyboard.</p><p>With this practice, your team, your next coder wont spend hours to dig in the folders to find out what is what. The “goto definition” would be more efficient with this naming approach.</p><p>Also, the root module can call other sub module dynamically using a func like this:</p><p><strong><em>func loadViewControllers(_ named: String) {<br> let storyboard = UIStoryboard.init(name: named, bundle: nil)<br> let targetViewController = storyboard.instantiateViewController(withIdentifier: named) <br> self.navigationController?.pushViewController(targetViewController, animated: true)<br> }</em></strong></p><p>This is not ideal yet, as we will need to call the module as blackbox with param. However, we must apply this naming approach to enable the blackbox in the first place. We will discuss this soon enough.</p><h3>Using static table</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/322/1*A3xZjj_UcPH0rQHmQpu3yQ.jpeg" /><figcaption>Static or Dynamic table?</figcaption></figure><p>Why on earth everytime I asked people, the answer always is that have to do dynamic table view with custom cell for image and 2 label views.</p><p>For the cell, the image and 2 labels are actually predefined. We dont need custom cell, we dont need to add them, they are already there even they are invisible on storyboard.</p><p>If you already bind the cell -say cell1 -, you can just call the image like this cell1.imageView.image = …</p><p>Here from apple document in <a href="https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/TableView_iPhone/TableViewCells/TableViewCells.html">https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/TableView_iPhone/TableViewCells/TableViewCells.html</a></p><p><strong><em>“The </em></strong><strong><em>UITableViewCell class defines three properties for this cell content:</em></strong></p><ul><li><a href="https://developer.apple.com/documentation/uikit/uitableviewcell/1623210-textlabel"><strong><em>textLabel</em></strong></a><strong><em>—A label for the title (a </em></strong><a href="https://developer.apple.com/documentation/uikit/uilabel"><strong><em>UILabel</em></strong></a><strong><em> object)</em></strong></li><li><a href="https://developer.apple.com/documentation/uikit/uitableviewcell/1623273-detailtextlabel"><strong><em>detailTextLabel</em></strong></a><strong><em>—A label for the subtitle if there is additional detail (a </em></strong><strong><em>UILabel object)</em></strong></li><li><a href="https://developer.apple.com/documentation/uikit/uitableviewcell/1623270-imageview"><strong><em>imageView</em></strong></a><strong><em>—An image view for an image (a </em></strong><a href="https://developer.apple.com/documentation/uikit/uiimageview"><strong><em>UIImageView</em></strong></a><strong><em> object)</em></strong></li></ul><p>“</p><p>The subviews in the cell have been predefined and formatted. We just use them, no need for custom cells and dynamic table.</p><p>You can still add your own image and labels in the cell, in case you prefer different presentation, like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/201/1*AN6w6UQJKRq24QzVL_5mwg.png" /><figcaption>profile with static table</figcaption></figure><p>In summary, for the views that dont require dynamic table, dont use it.</p><p>Why? simply because static table loads much much faster than dynamic table. My test result is up to 10 times faster.</p><p>…</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6061d0e8c403" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>