vinayhulgar / ArticlePrograms

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ“— Articles

πŸ”° Liskov Substitution Principle in 3 Minutes

πŸ“ŒThe LSP, in simple terms, states that objects of the same superclass should be able to be swapped with each other without breaking anything.
πŸ“Œ If we have a Cat and a Dog class derived from an Animal class, any functions using the Animal class should be able to use Cat or Dog and behave normally.

πŸ”° To demonstrate how to group a list of Strings by creating a WordCounts class which includes:

πŸ“Œ getWordCounts – group a given sentence by its word’s counts
πŸ“Œ getWordLength – group a given sentence by its word’s length
πŸ“Œ getWordLength_List – group a given sentence by its words’ length, return it as a List
πŸ“Œ getWordLength_Set – group a given sentence by its words’ length, return it as a Set
πŸ“Œ getwordLength_String – group a given sentence by its words’ length and return it as a String

πŸ”° Combining Predicates:

πŸ“Œ We can use lambda expressions to define our Predicate or implement the Predicate interface. If we want to combine different Predicate objects, we can use the or, and, and negate methods of the Predicate interfaces. These are default methods of the interface and will return a new Predicate.

πŸ”° Shuffle Playlist:

πŸ“Œ It’s October 2001 and Apple is releasing the first iPod, which will revolutionize the portable media player market. Your job is to implement the song shuffle feature. Using your favorite programming language (Java), you need to implement this feature.

πŸ”° Tell Don't Ask Principle:

πŸ“Œ It is a principle that helps people remember that object-orientation is about bundling data with the functions that operate on that data. It reminds us that rather than asking an object for data and acting on that data, we should instead tell an object what to do. This encourages to move behavior into an object to go with the data. https://dev.to/guifroes/solving-real-world-bad-design-by-applying-the-tell-don-t-ask-principle-607

About


Languages

Language:Java 100.0%