Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Let me start by saying that, personally, an OOP principle that does not work on both dynamically and statically typed languages isn't a principle.</p> <p>That said, here is an example: </p> <p>The Interface Segregation Principle (<a href="http://objectmentor.com/resources/articles/isp.pdf" rel="nofollow noreferrer">http://objectmentor.com/resources/articles/isp.pdf</a>) states that clients should depend on the most specific interface that meets their needs. If client code needs to use two methods of class C then C should implement interface, I, containing only these two methods and the client will use I rather than C. This principle is irrelevant in dynamically typed languages where interfaces are not needed (since interfaces defined types, and types are not needed in a language where variables are type-less)</p> <p>[edit]</p> <p>Second example - The Dependency Inversion Principle (<a href="http://objectmentor.com/resources/articles/dip.pdf" rel="nofollow noreferrer">http://objectmentor.com/resources/articles/dip.pdf</a>). This principle argues is "the strategy of depending upon interfaces or abstract functions and classes, rather than upon concrete functions and classes". Again, in dynamically typed language client code does not depend on anything - it just specifies method signatures - thereby obviating this principle.</p> <p>Third example - Liskov Substitution Principle (<a href="http://objectmentor.com/resources/articles/lsp.pdf" rel="nofollow noreferrer">http://objectmentor.com/resources/articles/lsp.pdf</a>). The text book example for this principle is a Square class that subclasses a Rectangle class. And then client code that invokes a setWidth() method on a Rectangle variable is surprised when the height is also changed since the actual object is a Square. Again, in a dynamically typed language the variables are type-less, the Rectangle class will not be mentioned in the client code and hence no such surprises will arise. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload