Sunday, July 12, 2015

Object Design Miscs



http://programmers.stackexchange.com/questions/159207/using-business-objects-in-view-models
Option 1 creates a tight-coupling between the domain model and the view. This contravenes the very problem view models are designed to solve.
A view models "reason to change" is if the view itself changes. By putting a domain model object in the view model, you're introducing another reason to change (eg the domain changed). This is a clear indication of a violation of the single responsibility principle.

http://www.hihuyue.com/hihuyue/interview/about-oop
2. What is An Object?An object can be considered a “thing” that can perform a set of activities. The set of activities that the object performs defines the object’s behavior.
3. Benefits of OOP?– Testability/Increased Quality (automated testing can increase speed of testing and increase quality)
– Code re-use (Polymorphism, Generics, Interfaces)
– Code extensibility
– Catch errors at compile time rather than at runtime.
– Maintainability: If designed correctly, any tier of the application can be replaced by another that implements the correct interface(s), and the application will still work (can use multiple user interfaces, can swap out data providers, etc.).
– Reduces large problems to smaller, more manageable ones.
– Fits the way the real world works. It is easy to map a real world problem to a solution in OO code.
4.Three important features of OO Programming LanguageEncapsulation, Polymorphism, Inheritance
Encapsulation
In object-oriented programming, objects interact with each other by messages. The only thing that an object knows about another object is the object’s interface. Each object’s data and logic is hidden from other objects. In other words, the interface encapsulates the object’s code and data.
This allow the developer to separate an object’s implementation from its bahavior. 

This separation creates a “black-box” affect where the user is isolated from implementation changes. As long as the interface remains the same, any changes to the internal implementation is transparent to the user. 

For example, if the name message is sent to the Student object, it does not matter to the user how the developer implemented the code to handle this message. All the sending object needs is the correct protocol for interacting with the Student object. The developer can change the implementation at any time, but the name message would still work because the interface is the same.
Polymorphism
Another benefit of separating implementation from behavior is polymorphism.
Polymorphism allows the sending object to communicate with receiving objects without having to understand what type of object it is, as long as the receiving objects support the messages.
The purpose of polymorphism is to implement a style of programming called message-passing, in which objects of various types define a common interface of operations for users. In strongly typed languages, polymorphism usually means that type A somehow derives from type B, or type C implements an interface that represents type B.
Polymorphism (which is strictly referring to subtype polymorphism in the context of this article) is not the same as method overloading or method overriding (which is known instead as ad-hoc polymorphism). 

Polymorphism is only concerned with the application of specific implementations to an interface or a more generic base class. 
Method overloading refers to methods that have the same name but different signatures inside the same class. Method overriding is where a subclass replaces the implementation of one or more of its parent’s methods. 
Neither method overloading nor method overriding is by itself an implementation of polymorphism.
Ad hoc polymorphism
Ad hoc polymorphism is a kind of polymorphism in which polymorphic functions can be applied to arguments of different types, because a polymorphic function can denote a number of distinct and potentially heterogeneous implementations depending on the type of argument(s) to which it is applied. It is also known as function overloading or operator overloading.
Inheritance
Another important concept of object-oriented programming is inheritance. Inheritance allows a class to have the same behavior as another class and extend or tailor that behavior to provide special action for specific needs.

Labels

Review (572) System Design (334) System Design - Review (198) Java (189) Coding (75) Interview-System Design (65) Interview (63) Book Notes (59) Coding - Review (59) to-do (45) Linux (43) Knowledge (39) Interview-Java (35) Knowledge - Review (32) Database (31) Design Patterns (31) Big Data (29) Product Architecture (28) MultiThread (27) Soft Skills (27) Concurrency (26) Cracking Code Interview (26) Miscs (25) Distributed (24) OOD Design (24) Google (23) Career (22) Interview - Review (21) Java - Code (21) Operating System (21) Interview Q&A (20) System Design - Practice (20) Tips (19) Algorithm (17) Company - Facebook (17) Security (17) How to Ace Interview (16) Brain Teaser (14) Linux - Shell (14) Redis (14) Testing (14) Tools (14) Code Quality (13) Search (13) Spark (13) Spring (13) Company - LinkedIn (12) How to (12) Interview-Database (12) Interview-Operating System (12) Solr (12) Architecture Principles (11) Resource (10) Amazon (9) Cache (9) Git (9) Interview - MultiThread (9) Scalability (9) Trouble Shooting (9) Web Dev (9) Architecture Model (8) Better Programmer (8) Cassandra (8) Company - Uber (8) Java67 (8) Math (8) OO Design principles (8) SOLID (8) Design (7) Interview Corner (7) JVM (7) Java Basics (7) Kafka (7) Mac (7) Machine Learning (7) NoSQL (7) C++ (6) Chrome (6) File System (6) Highscalability (6) How to Better (6) Network (6) Restful (6) CareerCup (5) Code Review (5) Hash (5) How to Interview (5) JDK Source Code (5) JavaScript (5) Leetcode (5) Must Known (5) Python (5)

Popular Posts