Wednesday, March 31, 2021

SOLID PRINCIPLES

SOLID Principles by Robert Martine .. Uncle Bob. Clean Code - Mantainable - Easy to understand/Transperent. - Extensiable Bird class and fly function for all types of birds. Bird class and fly fucntion having all 50 birds fly behaviour under one fly function with multiple if else cases. bad programming and increase testing efforts. 1-- Single responsiblity Principles. -- Hen and Eagle seprate class where as common bird class inherited. -- should have one reasons to get change for that specific class. -code should not have multiple if else conditions. ( need refactor ) -should not have large method. -unspecified utillity and helper class. all helper utility class should be specific. 2-- Open close Principles ables to change the code without impacting the existing code. open for extension and closed for modifications. Employee and tax computation with different tax calculations. Different type tax caluclatore for differnt types of employee.. Interface of Tax calulatore should be used on each concreat class. class represent an tangiable objet is concreate class. Interface of Taxcalulator having calulate method. Then use factory design pattern. Interface is collection of behaviours. if we extendes multiple class lead to complecity. Book Refactoring Design priciples. when to use Interface and when to use Abstract Abstract when there is no concreate ecommerce-->flipkart,amazone or elearing-->scaler,umedy , Bird class. Interface when there is a behaviour across class-- > Bird having fly method. where fly method can be used for MIg21,Airbus so common functionality can be use acrss multiple class. 3-- Liscove Subsitution Priciples if penguin, kiwi are bird but do not fly then ? solve by using a fly method as Interface. No clase should force to implement any method which it cannot perform. An object of the parent class should be completlytly replease by object of child class. eg stack class extends arraylist where oject of stack voilate Livoskey pricniple to over come we compose arraylist oject inside the stack, Is a relaton to has a relastion. Inheritacne bring complexity if not used properly, there are some child class not able to take common parent methods. -- wrong inheritance. solved by remove inheritance by remove the method as Interface. -- MultiLevel of Inheritance lead to complex code. diamond inheritance issues. -- Use of Interface will ease the implmentation with multiple Interface in use. it provide better level of abstractions. -- bird class sholuld be abstrat and shold not use fly interface. stategic desing pattern remove multilevel inheritance. follow LSP. 4-- Interface segregation principle. All the birds have differnt type of flywing methods. fly with differnt way landing falp wing. Inrterfae should be lean,focused with specific type of methods. Instead of big Interface it should have thin Interface where it follow Solid principle. 5-- Dependency Inverson principle. Dependenct define as association/composition eg : car and engin class. car higher level and engin as lower level, both should not depends on concrete clase, both of them depends on abstractions eg ecommere product class dependent on sqlProductDB class. to avoid dependency implement abstract class productRepo it could be SQL or MongoDB we have Dependency Injection where in the abstract class construction have the oject paramter of type of object required. Inversion of control import the object to an container. ( creation of object to external srvices) eg spring framwork in Java. association -- way two class dependent with each other ( car, engin, tyre) asso two type -- Aggreggation/composition composstion given class compose the depedent class.( appartment room) has a relations two objec an still leave without each other ( doctor patient ) has many relation Telegram link - https://t.me/joinchat/AAAAAEtM4MxyuVdALwJhgA Discord channel link - https://discord.gg/ejFeksEtTq

Saturday, August 28, 2010

Wednesday, April 21, 2010

My World My Dreams..



It doesn't matter for how long the room has been dark; For a day, or a week, or a year, or for ten thousand years. The moment you bring in a candle; darkness vanishes like it was never there. Similarly, it doesn't matter for how long we are stuck in a sense of our limitations. The moment you decide to break free, nothing will stop you. Create the light of your life.