Clean Function: Command Query Separation

command functions are: deleteSessionRegistry calculateMonthlyFee publishArticle sentEmailReport query functions are: getName getNettPayroll getDiscount If you are programmers you should spot the differences. Command function should do something and the query function should answer something. But have you found a function like this def calculate_nett_payroll response_tax_service = get_user_tax(@user.id) if response_tax_service.status == 200 @payroll_net = @payroll_gross - response_tax_service.body.tax_amount return "ok" end return "nok" end Those are command query but returning something just like the query function, leads to confusion.

Clean Function: Using Exception to Return Error Code

Experienced programmers must have faced cases where a process within function needs to be checked. Some programmers will create a function that returns the status of the process or returning an error code. For example, a function that sent a request to external web services, and the response of web services should check whether a success response, error response or timeout. def calculate_nett_payroll response_tax_service = get_user_tax(@user.id) if response_tax_service.status == 200 @payroll_net = @payroll_gross - response_tax_service.

Server Sent Events (SSE) You Need to Know

Server Sent Events (SSE) is like a common client-server HTTP request, instead of waiting for a response from the server, the client can get events during that time from the server. SEE use when : While thinking implement WebSocket, (communication will happen bi-directionally) but client no need to sent an event to the server. Want chunk response instead of waiting all process to be completed in one request When to don’t use it

Code That Breaking SRP

What is SRP? Single responsibility principle (SRP) states that a class or module should have one, and only one reasone to change. Robert Cecil Martin (2008) Clean Code, : . #1 public class UserValidator { private Cryptographer cryptographer; public boolean checkPassword(String userName, String password) { User user = UserGateway.findByName(userName); if (user != User.NULL) { String codedPhrase = user.getPhraseEncodedByPassword(); String phrase = cryptographer.decrypt(codedPhrase, password); if ("Valid Password".equals(phrase)) { Session.initialize(); return true; } } return false; } } Robert Cecil Martin (2008) Clean Code, : .

Add Proper Index Table For Slow Query MYSQL

For software engineer especially on the backend, might have faced issue slow query in the Production environment. This happens when the query that builds in the development environment only has small data set and shows good query time. Maybe first-time query landing on production environment everything just fine, just like a time bomb, production dataset getting bigger and the query time is slowing down and your alert system notifies you for the slow query, or database CPU got high.

Object-oriented Design: Tell Don't Ask

“Tell don’t ask” is one of the tricks to doing object-oriented design. So what it means? You should not “ask” something from an object to do a logical result, but you should “tell” the object to do it. user = User.new('subscriber') if user.type == 'subscriber' user_price = 10 else user_price = 50 end It’s better when class User def price user.type == 'subscriber' ? 10 : 50 end end user = User.

Object-oriented Design Mindset?

This topic is bothering me for years, how to make a programmer has an object-oriented design mindset? Popular codes I have seen during my working experience as a programmer, are it is procedural programming, wrote at an MVC framework, in a controller method. The controller becomes a massive code and hard to read. Sometimes I found there are “service pattern”, typically named with {domain}Service. Most of the time this service class becomes a big chunk of the instance method.

Database Quran Indonesia

Kali ini saya mau berbagi database Al-Quran Indonesia yang mana sangat bermanfaat bagi rekan para developer aplikasi yang akan membuat aplikasi Al Quran Indonesia. Database ini masih berupa SQL script (.sql) yang di dalamnya hanya melakukan proses create table dan insert saja. Membagi pengalaman saya dalam membuat aplikasi Zikir dan Quran, saat awal pengembangan aplikasi saya mengambil data Quran dari http://www.qurandatabase.org/. Akan tetapi masih ada beberapa kekurangan dimana ada harkat yang di baca panjang tapi tidak tertulis panjang, sepertinya layaknya Al-Quran cetakan Indonesia.

Ridhar Studio

I build some app that exist on Play Store (Android). Check this: Zikir Indonesia - https://play.google.com/store/apps/details?id=com.zikirindonesia My first app, that I build base on my needs of an zikr app that include a counter feature on each zikr. Now this App also have Al-Quran and translation and have a special feature, Khatam prediction date. My IP Now - https://play.google.com/store/apps/details?id=com.com.ridhar.ipapp You need to remember your used IP? JR Plan Poker - https://play.

About Me

My name is Ridha Ramadhansyah, I a muslim, software engineer base on Jakarta, Indonesia. You will find my writes on this site. Find Me: sinoridha@gmail.com https://www.linkedin.com/in/ridharamadhansyah/ https://github.com/sinoridha