C
C#8mo ago
Drama Llama

✅ Design Pattern Advice

Hi everyone! I'd like to write a small calendar app, and the key feature I'd like it to have is being able to work with a number of different APIs, like google calendars or outlook. What would be the best design pattern to look into for something like this? I've been reading into adapter and factory.
9 Replies
Pobiega
Pobiega8mo ago
Not sure I'd call this a "design pattern" problem, as you more or less just need to create a IExternalCalendar interface that represents the actions you want your program to be able to handle (fetching events, pushing new events etc), then implement that interface for each external provider
Drama Llama
Drama Llama8mo ago
This is less about getting the job done and more about practicing, following best practices and of course, sounding better in the documentation
Esa
Esa8mo ago
Doesn't change Pobiegas point though, best practises here would revolve around having good integrations that implement an interface that makes sense.
Pobiega
Pobiega8mo ago
I guess you could call this an implementation of the adapter pattern, if you wanted to put a name on it but its the only sane way to solve this particular problem its not like all patterns solve the same problems, or are silver bullets in general
Drama Llama
Drama Llama8mo ago
Thank you, this was very helpful! Or rather, is :) (And yes, putting a name on it makes me feel better. I'll certainly look into interface best practices though!)
Pobiega
Pobiega8mo ago
its not strictly the adapter pattern thou, as the idea there is that you have an object and "wrap" it in an adapter thats not what you do here, you simply implement an interface
Drama Llama
Drama Llama8mo ago
noted! that's good to know!
Mayor McCheese
Mayor McCheese8mo ago
Design patterns are good to learn as they codify things that you are probably already doing and provide justification and consequences for such choices. You won't need to follow the prototypical implementation in practice.
Accord
Accord8mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.