Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Code Modularization

Taka
August 31, 2018

Code Modularization

Tech Talk for non-engineers at IMMO Investment Technologies on 31st August 2018.
IMMO Investment Technologies: https://www.linkedin.com/company/immoinvesttech/

Taka

August 31, 2018
Tweet

More Decks by Taka

Other Decks in Programming

Transcript

  1. Good Software (in my opinion) • “At least” needs to

    meet the business requirements ◦ Software that doesn’t meet the requirements is rubbish ▪ What if Twitter didn’t have the feature to tweet your thoughts... • Should be extensible, maintainable, and reusable ◦ Because...
  2. Business Requirements • Business requirements frequently change ◦ We may

    come up with a better idea 3 days after we decide something important • New requirements constantly show up ◦ We may want to launch a new service or feature instead of refining existing ones
  3. Updating Software • Software should be updated as quickly as

    possible ◦ All of us want to deploy new features as soon as possible and ahead of competitors. • Software should be as understandable as possible ◦ The more your business grows, the more developers join you. It’s obvious that newcomers can easily catch up if the software is understandable.
  4. What If Requirements Never Change If we are 100% sure

    requirements won’t change forever and there is no need to maintain the software, extensibility, maintainability, and reusability don’t matter. It might be possible in some special occasions, but practically, it hardly ever happens when you are developing services.
  5. Before Doing Pringles... I’m going to use ‘mathematical-function-like-programs’. f(x) =

    y • f: the name of the function (program) • x: the parameter of the function (program) • y: the result of the function (program) given ‘x’
  6. Example of a Function calculate_property_value(postcode, number_of_bath_rooms) • Program name: calculate_property_value

    • Parameters: postcode, number_of_bath_rooms • Result: the value of the given information This program will calculate the property value based on the given postcode and the number of bath rooms.
  7. Simplified Processes of Production 1. Grow Potatoes 2. Cut Potatoes

    3. Fry Potatoes 4. Season Potatoes 5. Pack Potatoes 6. Ship it!
  8. Simplified Processes of Production 1. Grow Potatoes 2. Cut Potatoes

    3. Fry Potatoes 4. Season Potatoes 5. Pack Potatoes 6. Ship it! Let’s make a program to do these 4 steps!
  9. The Program to Make You can pass potatoes and this

    program will produce pringles! produce_pringles(potatoes) = a_pack_of_pringles • Name: produce_pringles • Parameters: (potatoes) • Result: a pack of pringles
  10. Use Case of the Program 1. Jed cultivates potatoes 2.

    Nino receives potatoes from Jed and uses the ‘produce_pringles’ program 3. The ‘produce_pringles’ program produces Pringles 4. Nino sends Pringles to Taka 5. Taka enjoys Pringles!
  11. Usage of the Program As long as you have enough

    potatoes, you can produce as much as Pringles you want by using this program. If Nino has 100 units of potatoes (1 unit is for one pack of Pringles), Nino can get 100 packs of Pringles by calling ‘produce_pringles’ 100 times.
  12. Nino’s Job with and without the Program Without the Program

    1. Cut potatoes 2. Fry potatoes 3. Season potatoes 4. Pack potatoes 5. Ship it With the program 1. Use the program 2. Ship it
  13. Details of the Current Program What is happening inside the

    program is: • Cut potatoes • Fry potatoes • Season potatoes <= Using only salt right now • Pack potatoes
  14. Comparison between two programs produce_pringles 1. Cut potatoes 2. Fry

    potatoes 3. Season potatoes with salt 4. Pack potatoes produce_pringles_beer_flavord 1. Cut potatoes 2. Fry potatoes 3. Season potatoes with beer 4. Pack potatoes
  15. Closer look at Cut Potatoes I haven’t told it, but

    cutting potatoes consists of 10 steps. 1. Wash potatoes 2. Peel potatoes 3. etc.
  16. More Realistic Details of Two Programs produce_pringles 1. Cut potatoes

    (10 steps) a. Wash potatoes b. Peel potatoes c. And so on... 2. Fry potatoes (5 steps) 3. Season potatoes with salt (12 steps) 4. Pack potatoes (3 steps) produce_pringles_beer_flavord 1. Cut potatoes (10 steps) a. Wash potatoes b. Peel potatoes c. And so on... 2. Fry potatoes (5 steps) 3. Season potatoes with beer (12 steps) 4. Pack potatoes (3 steps)
  17. The regulation of washing potatoes has changed! You need to

    update your software to follow the new law!
  18. Updated Two programs produce_pringles 1. Cut potatoes (10 steps) a.

    Wash potatoes b. Sanitize potatoes c. Peel potatoes d. And so on... 2. Fry potatoes (5 steps) 3. Season potatoes with salt (12 steps) 4. Pack potatoes (3 steps) produce_pringles_beer_flavord 1. Cut potatoes (10 steps) a. Wash potatoes b. Sanitize potatoes c. Peel potatoes d. And so on... 2. Fry potatoes (5 steps) 3. Season potatoes with beer (12 steps) 4. Pack potatoes (3 steps)
  19. Updated Programs with new modules produce_pringles 1. cut_potatoes(potatoes) 2. fly_potatoes(potatoes)

    3. season_potatoes(potatoes, salt) 4. pack_potatoes(potatoes) produce_pringles_beer_flavord 1. cut_potatoes(potatoes) 2. fry_potatoes(potatoes) 3. season_potatoes(potatoes, beer) 4. pack_potatoes(potatoes) To cope with the new potato law, you no longer need to modify two places. Instead, you just need to update the ‘cut_potatoes(potatoes)’ program!
  20. Look for similarity for further abstraction produce_pringles 1. cut_potatoes(potatoes) 2.

    fly_potatoes(potatoes) 3. season_potatoes(potatoes, salt) 4. pack_potatoes(potatoes) produce_pringles_beer_flavord 1. cut_potatoes(potatoes) 2. fry_potatoes(potatoes) 3. season_potatoes(potatoes, beer) 4. pack_potatoes(potatoes) Most parts of both programs are pretty much the same! You may make a new program that is more reusable!
  21. Benefits of the new one • You only need to

    maintain only one program, instead of two • You don’t need to create a new program to produce a new flavored Pringles
  22. Summary • Code Modularization is for ◦ Maintainability ◦ Extensibility

    ◦ Reusability ▪ Each of which is for updating software to meet the requirements