This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1) World is Procedural : sequence of actions like human is getting up, taking bath, going office, return home | |
2) World is also Object oriented : interacting with people : spouse_step_on_cat (heart beat increses for cat and also for spouse) | |
3) OOD takes us to collection of predefined procedures to messages passing between objects | |
4) How to learn OOD : Immerse yourself in objects | |
5) Software is being built for reason like hospital management, games, etc. | |
6) If we dont need to change design not matters but changes are unavaidable | |
7) Why change is hard: having more dependency, not proper designed coding | |
8) SOLID : Single responsibility, Open-Closed, Liskov Substitution, Interface Segregation, Dependency Inversion | |
9) DRY - Dont Repeat Yourself and Law of Demeter | |
10) How design fails : due to less designed code which can add feature but it will break everything on other hands, can not add feature as it was not designed to do that |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Recognize Dependency : | |
-> A class has another class | |
-> calls method in another class | |
-> Args that message(method) requires. Gear knows Wheel.new | |
requires rim and tire as well as order of Args. | |
More coupling -> More dependency | |
Tightly coupled two objects act as single entity | |
Avoid message chaining on different objects | |
If you cannot remove dependency from class just isolate them. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Class : Doing possible smallest thing | |
Change : | |
-> no side effects | |
-> small change in requirement require small change in code | |
-> existing code should be easy to reuse | |
-> add code that in itself must be easy to change further | |
TRUE princliple | |
High cohesion : High single ersposibility | |
Depend on behaviour not on data. | |
Hide Data Structures(cell[0]: rim, cell[1]: tire) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Interface : method inside class which should be communicate with other objects with clear message pattern. | |
Ex : Kitchen | |
-> serve() is necessary but cookingManner() is not necessary. | |
-> Make them appropriate private or public interfaces | |
Use UML, Sequence diagram | |
Ask for what not for how | |
Reduce Law of demeter(Message chaining) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Duck Typing : | |
-> Abstract class / interface | |
-> To make code to be easy to change | |
-> increases flexibitlity | |
Statically Typing VS Dynamically Typing | |
Meta Programming : Writing code that writes code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Classical inheritance : | |
Message delegation to another object if one object is not respond to message. | |
-> find abstraction and create abstract class. | |
-> Unresponsed messages are automatically delegated(forwarded) to its super class and so on. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-> light weight framework used to build any type of java apps | |
-> its non-invasive : does not force a programmer to extend any predefined class (like struts) | |
-> features : | |
-> simplicity (non-invasive) | |
-> testability (no need server/container) | |
-> lightly coupling | |
-> modules in spring 1.x : | |
-> core module | |
-> context module (J2EE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-> HTTP request are handled by controller. | |
-> @RestController over class | |
-> @RequestMapping("/path", METHOD=GET/POST....) over method | |
-> @RequestParam(value="name", defaultValue="Some Default Values") : these are query string params in url/ by default its set to required = false | |
-> java.util.concurrent.atomic.AtmoicLong is counter which returns specified Rest Object | |
-> Now converting object to JSON by MappingJackson2HttpConverter which is inside spring's Jackson2. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-> No SQL (Non-Relational, full of documents) | |
-> Database - Database, Table - Collection, Tuple - Document, column - field, table join - document embed | |
-> unique id for every object | |
-> id will be 12 byte hex, 4 = timestamp, 3 = machine id, 2 = process id of mongo server, 3 = incremental value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void NetworkCall() { | |
RequestQueue queue; | |
StringRequest stringRequest; | |
queue = Volley.newRequestQueue(getApplicationContext(),new HurlStack(null, createSslSocketFactory())); | |
stringRequest = new StringRequest(Request.Method.POST, "https://www.thehellofood.com/restaurantapi/getFoodItems", new Response.Listener<String>() { | |
@Override | |
public void onResponse(String response) { | |
try { | |
Log.e("response", response); | |
} catch (Exception e) { |
OlderNewer