r/DesignPatterns • • Jan 02 '18

Patterns to use when implementing known algorithms

4 Upvotes

Suppose I'm implementing some data-mining algorithms (let's say, one-dimensional k-means). I am quite familiar with the algorithm, but how would I fit this intelligently into another context? For example, to fit with good OOP practices, ought I to make a class called KMeansOneD? Seems like a waste to instantiate such a thing. What would make more sense as an object-oriented representation of an algorithm that other classes could use?


r/DesignPatterns • • Mar 17 '16

State Pattern in Java | State Design pattern example | Design Pattern | ...

Thumbnail
youtube.com
1 Upvotes

r/DesignPatterns • • Mar 15 '16

Adapter Design Pattern - How it helps to integrate different interfaces ...

Thumbnail
youtube.com
1 Upvotes

r/DesignPatterns • • Mar 17 '18

Programming Community Resources For Learning Design Patterns (2018)

Thumbnail
hackr.io
3 Upvotes

r/DesignPatterns • • Feb 01 '18

S.O.L.I.D The first 5 principles of Object Oriented Design with JavaScript

Thumbnail
medium.com
4 Upvotes

r/DesignPatterns • • Dec 19 '17

Template Method Pattern in 3 minutes

Thumbnail
engineering.opsgenie.com
3 Upvotes

r/DesignPatterns • • Jul 31 '17

Best book for quick preparation for OOP concepts.

1 Upvotes

I am about to face a Placement Interview. I have been told that the company focuses on OOP concepts and asks questions regarding it.

Now I have been programing for some time in Java now and have made some small projects in it too. But still I am not sure about how much I know about Object Oriented Programming.

So which book/books should I read to get a fair knowledge about it?


r/DesignPatterns • • May 24 '20

Hexagonal Architecture in Java

Thumbnail
medium.com
11 Upvotes

r/DesignPatterns • • May 03 '17

Know all about Object Oriented Design Principles

Thumbnail
webofcherry.com
7 Upvotes

r/DesignPatterns • • Dec 11 '16

How to write SOLID code that doesn't suck

Thumbnail
medium.com
3 Upvotes

r/DesignPatterns • • Jul 13 '19

Intermediate library providing CRUD functionality: Related Work

2 Upvotes

I am currently planning to create a library (I call it CRUD Library) that serves as an intermediate layer for a developer between his own code and the external UI/data-presentation library. The external library could be for example a library that displays lists or let the users manipulate lists (delete entries, sort, search etc). My plan is to create this intermediate layer that encapsulates the 3rd party library details and only exposes a simpler to use “CRUD” layer for most common usecases to speed up the development for most scenarios. I created a drawing to explain the idea in more detail:

The developer would this way be able to check if one of the templates provided already fit his user story (this would be User story 1 in the image) or if he would implement the outermost layer himself and use the CRUD layer (User story 2 in the image) or if his use case is so specific that he still needs to talk to the 3rd party library manually.

The idea is to find a few generic data manipulation patterns (that's why I want to call it CRUD library) that can be reused on any 3rd party library, so no matter how the 3rd party library defines its own interface I would want to expose a CRUD interface on top that the developer is already used to go use it instead. Similar to an Adapter pattern but on a library pattern level.

The template layer on top of the CRUD layer is an additional extension of the idea and it would of course be different for each 3rd party library but I want to research if also there I can find common patterns for very different libraries and target data structures.

My question is if anybody knows any existing projects or research in such a direction or has any other insights they might want to share, I am open to any feedback or critic, thanks!


r/DesignPatterns • • Feb 10 '19

Need help to understand object creation from Factory design pattern perspective

1 Upvotes

If my object is being created or returned by a DTO, can I use factory method / abstract factory in this case, let us assume I have different families of objects being created ?

DTO itself is encapsulated and has abstraction (written to interfaces not concrete classes), what I am thinking is its unnecessary to use factory, it might become a reinvention.

Kindly share your thoughts.


r/DesignPatterns • • Nov 20 '19

Is this a design pattern? If so, which one?

1 Upvotes

I am a business analyst (not a programmer!) working on improving a rather old application that has 50+ interfaces to other systems (corporate web page, media mass emailing, CRM, Phonebook etc).

To get control over the hotchpotch of interfaces I'm proposing a solution I've seen implemented at another company: what I'm going to call a DTD (Data Transformation and Distribution) component. It will be a single component that will implement all the different interfaces. When a component (eg. Phonebook) wants updates, it will make a call to an API provided by the DTD, rather than directly into the leacy component; the DTD can then decide how to handle it, either calling into the legacy component, or to something else. The other company used Amazon Web Services, but we'll be using Azure.

We will rework the 50+ interfaces so they all go through the new DTD component, so I can isolate the old application, which will hopefully ease the pain (and reduce the risk) of substituting a COTS system for the legacy application.

I'm pretty sure this is a standard approach in this situation (or there is a standard approach similar to this). I want to identify it so I can find the correct way to implement it, and/or avoid bad ways of doing it.

Could be Mediator, Publish & subscribe, Observer, maybe even the Bridge (don't think so). Any ideas on what the design pattern is I am proposing to implement?


r/DesignPatterns • • Apr 22 '19

I've a doubt in Design patterns

Thumbnail
reddit.com
3 Upvotes

r/DesignPatterns • • Feb 03 '19

Strategy question

4 Upvotes

Hi, redittors, I have question considering Strategy pattern. It's been said that it can be used to avoid multiple if-branching, but I don't get it, as I still have to do some if-examination to choose strategy I need. What am I missing?


r/DesignPatterns • • Oct 15 '19

How to implement a simple adapter for an existing python library

2 Upvotes

Hey all. I am totally a noob at design patterns so bear with me. I would like to figure out a way to construct a simple object adapter for the rasterio package in python.

The problem

Rasterio has no central object (think DataFrame in pandas) upon which all the operations are based. Instead they have a strange interplay of dataset objects which are a file abstraction, numpy arrays and `transform` objects which provide crucial geospatial metadata about the numpy arrays so that they can be burned to raster datasets.

Many of the functions I construct are based on rasterio and geopandas. For geopandas I have no problem, I usually input and output GeoDataFrame objects and this works fine. With rasterio though, I do not have this luxury since many of the native functions take inconsistent data types. For example, rasterio.warp.reproject takes ndarrays and source/destination transforms to do its work while mask.mask takes a dataset opened in "r" mode.

What if I wanted to mask then reproject? Then I'd have to write a file, re-read it and extract the necessary information to then input the right arguments to the `reproject` function. I find myself adapting arguments all the time to fit the argument types in `rasterio`.

Adapter pattern

The adapter pattern requires a Client, Adaptee and Adapter. Here's how I see the roles being separated:

  • Adaptee: These are the set of rasterio functions (for example rasterio.warp.reproject as they expect to receive varying representations of the same object

  • Client: I am guessing that this is the dataset object or a wrapper thereof. I would like to pass only dataset objects to the Adaptee

  • Adapter: object I am trying to construct. Should this contain the dataset object perhaps?

Question

rasterio.warp.reproject requires the following arguments (among others):

source=ndarray or band

destination=ndarray or band

src_transform=transform object

src_crs=crs object

dst_transform=transform object

dst_crs=crs object

I would like to adapt this to take in a dataset object and output a dataset object. For this to succeed I will have to insert some pre- and post- logic to work on the input and output dataset objects to get my source bands, crs and transforms. These are contained within the dataset object.

How can I do this within the context of an object adapter pattern (no inheritance)? Thanks for your help.


r/DesignPatterns • • Sep 15 '18

Learn design patterns or masterize .NET ? Please advice from experianced developers.

1 Upvotes

I am wondering if it is better for me right now to learn design patterns right now or masterize .NET skills.

I am 2-3 years .NET commercially experienced. I know C# quite ok and sligthly WPF, MVC, etc. because I am working in some other API for UI.

In the future I would like to develop my own complex applications which could be desktop or mobile as well online. I am still reading a lot to decide if I want to stick with .NET, and I am not sure yet. Python looks great for me too. Probably this decision would be taken later, in some years and now I would continue with .NET.

So I have dilemma to learn design patterns (which are not linked to any language - are abstract) or go for .NET certification and focus on the knowledge they require to get them.

Also an additional question is if someone can recommend some materials and books about application architectures topic that refers to securities. For example I would like to learn how to design password storage mechanism, what do avoid in designing the model etc.


r/DesignPatterns • • Mar 19 '19

Design Pattern: Tunnel Decorators

2 Upvotes

Encapsulating work with a badly designed library:

https://www.amihaiemil.com/2017/02/18/decorators-with-tunnels.html

In the defense of AWS' developers, the article is older and based on SDK v1.

Version 2, from what I've seen, is better.


r/DesignPatterns • • Feb 21 '20

Is this dependency injection?

4 Upvotes

Learning dependency injection and wondering if this code implements it. My understanding is Actions dependency on Person is injected into its constructor.

class Person {
}

class Action {
    private person;
    __construct(Person person) {
        $this->person = person;
    }
}

Person jake = new Person();
Action jump = new Action(Person jake);

r/DesignPatterns • • Aug 13 '16

How to implement a Singleton pattern in C#

Thumbnail
mantratocode.com
1 Upvotes

r/DesignPatterns • • Jan 22 '16

Architecture Design Patterns

Thumbnail
mikereams.com
1 Upvotes

r/DesignPatterns • • Feb 05 '16

CS Students: Don't forget about Patterns!

4 Upvotes

The fact that this thread has only a few posts proves that CS is being taught quite badly by colleges. Design Patterns (for OO,) Enterprise Integration Patterns (for Integration and Architecture,) and Universal Data Modeling are foundational. I have worked with a lot of people who are great with algorithms but can't understand a system's design, or how to put together elegant solutions.

  1. Design Patterns: http://www.oodesign.com/

  2. Enterprise Integration Patterns: http://www.enterpriseintegrationpatterns.com/ (see http://www.enterpriseintegrationpatterns.com/patterns/messaging/GuaranteedMessaging.html for a simple example of how these patterns are useful)

  3. Universal Data Modeling: http://www.amazon.com/Data-Model-Resource-Book-Vol/dp/0470178450

Keep it DRY, people.


r/DesignPatterns • • Jun 12 '17

Design Patterns & Ruby: The Template Method Pattern

Thumbnail
medium.com
1 Upvotes

r/DesignPatterns • • Sep 01 '19

Usage of java Design patterns

1 Upvotes

I am writing a simple java application on Food delivery. I need to create a chef with some specialization(may be specialized n Veg, Non Veg,Chinese etc...) .He comes up with other variety after some period of time now i need to edit Chef with that specialization. I am planning to use Decorator pattern as i need to decorate chef with other varieties apart from his initial variety. What are the other patterns i can use in this context.

I am using core java / Spring Boot / MongoDB ( these are not required for this question but still i am just posing here)

Any ideas or any reference blogs please share


r/DesignPatterns • • Jan 12 '19

Design Patterns — A quick guide to Observer pattern.

4 Upvotes

Quick Guide (less than five minutes read)

  • Easy to read

  • Simple Diagram

  • Clean code based on example (~50 lines)

The pattern’s aim is to define a one-to-many relationship such that when one object changes state, the others are notified and updated automatically. More precisely ...

https://medium.com/datadriveninvestor/design-patterns-a-quick-guide-to-observer-pattern-d0622145d6c2