Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

[DevDay 2017] Solid dev - Speaker: Vu Nguyen - Education Manager at Neolab Vietnam

133 views

Published on

After a couple of years working in software development, our speaker has realized that most young developers do not really have a thorough understanding of basic programming, resulting in your products generating many bugs, difficult for expansion and maintenance. Therefore, the presentation will give some programming principles especially for young devs with a hope that you could quickly become "solid" devs.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

[DevDay 2017] Solid dev - Speaker: Vu Nguyen - Education Manager at Neolab Vietnam

  1. 1. SOLID DEV Create by: Nguyen Viet Vu Education Manager
  2. 2. What’s a “Solid Dev”? Solid dev’s code is easy to: + Expand + Reusable + Maintenance + Debugging + Testing Neolab 4/2017 2/16
  3. 3. Principles 1. Learning from basic 2. Algorithm 3. Design pattern 4. Clean code 5. Optimizing each statements 6. S.O.L.I.D Neolab 4/2017 3/16
  4. 4. 1. Learning from basic Sample 1: Neolab 4/2017 4/16
  5. 5. Explanation • In decimal: c = 129 • But ranges of char type: -128 to 127 • So over number occurred. • Now what is output: • 129(Decimal) = 10000001(Binary) • Red 1 is sign bit(1: -(negative) 0:+(positive)) • Now what is output: • Negative number. • Value = 10000001 invert all bits then add 1 • Invert all bits: 01111110 • Add 1: 01111111 • So output: -127 Neolab 4/2017 5/16
  6. 6. 1. Learning from basic Sample 2: Neolab 4/2017 6/16
  7. 7. Explanation • a = 0 then (++a == 1) is true (increase a by 1 first then compare) • b = 0 then (b++ == 0) is false (compare first then increase b by 1) • Condition 2 is false so condition 3 is ignored. • So result is: case 2: 1, 1, 0 Neolab 4/2017 7/16
  8. 8. 2. Algorithm • Each issues have many ways to solve. • Should choose the optimum way. Eg: Check a positive integer is power of 2 or not? 32 is POT number because: 32 = 2^5 Neolab 4/2017 8/16
  9. 9. 2. Algorithm(cont) Neolab 4/2017 9/16
  10. 10. Explanation • A POT number(n) is represent in binary: 100000000 • (n-1) = 011111111 • n&(n-1) = 10000000 & 011111111 = 00000000 = 0 Neolab 4/2017 10/16
  11. 11. 3. Design Patten • Creational patterns Factory, Builder, Object Pool, Singleton, Prototype • Structural patterns Adapter, Bridge, Composite, Decorator, Façade, Flyweight,Private Class Data,Proxy • Behavioral patterns Chain of responsibility, Command, Interpreter, Iterator, Mediator, Memento, Null Object, Observer, State, Strategy, Template method,Visitor Neolab 4/2017 11/16
  12. 12. 4. Clean Code • No dead code • No compile warning • Low coupling/ high cohesion • DRY (Don't repeat yourself) • Coding convention Neolab 4/2017 12/16
  13. 13. 5. Optimizing each statements • Beware of the loops. • Pre-calculate values. • Use bit shift instead of multiplication and division. • Compare to zero is faster. • Rearrange IF statements. • Prefer static methods and local variables. Neolab 4/2017 13/16
  14. 14. 6. S.O.L.I.D • Single responsibility • Open-closed • Liskov substitution • Interface segregation • Dependency inversion Neolab 4/2017 14/16
  15. 15. Conclusion Neolab 4/2017 15/16
  16. 16. Thank for your listening Neolab 4/2017 16/16

×