#java question

1 messages ยท Page 1 of 1 (latest)

versed forum
#

Are the Strategy, Factory, and Repository widely used?

waxen acornBOT
#

<@&987246399047479336> please have a look, thanks.

versed forum
#

Hi !

waxen acornBOT
#

Here is an AI assisted attempt to answer your question ๐Ÿค–. Maybe it helps! In any case, a human is on the way ๐Ÿ‘. To continue talking to the AI, you can use </chatgpt:1108714622413963314>.

#
TJ-Bot
Are the Strategy, Factory, and Repository widely used?

Yes, the Strategy, Factory, and Repository patterns are widely used in Java development, each serving distinct purposes:

  • Strategy Pattern: Commonly used to define a family of algorithms, encapsulate each one, and make them interchangeable. This is useful for scenarios requiring dynamic behavior changes without altering the client code.

  • Factory Pattern: Frequently applied for object creation, abstracting the instantiation process to support loose coupling and enhance maintainability. It simplifies the code by hiding the creation logic, often seen in frameworks and APIs.

  • Repository Pattern: Popular in data access layers, particularly in enterprise applications. It abstracts the data source access, making it easier to change data storage implementations without affecting business logic.

Using these patterns helps improve code modularity, readability, and testability, aligning well with best practices in software design.


Useful links:

tribal tapir
#

Yes. Extensively. On all three counts.

solemn fog
#

note that is a different question than "is what I understand these words to mean a common definition and does widely used mean good and do other people use these words/techniques in the same way I am thinking"

versed forum
#

Ok tysm

#

Can someone give me an example of using Strategy, Factory, and Repository, please? Because I only know Bridge, State, and Decorator at this moment, I'm an IT Student

tribal tapir
#

A Strategy example we've used is one of time.

The strategy interface is TimeSource and offers nowLocalDate(), nowLocalTime(), etc

The usual implementation just backs onto the system default behaviours.

But we can inject an alternative strategy that lets us pause and then step through time. Combined with some system events and controls to 'reset', we can replay over a time-period in controlled steps or at an accelerated rate.

#

We've used the Factory pattern for preconfigured 'templates' that can then generate instances for each template (meaning we don't need to redo any of that template processing computation).

#

Repository is used in places as a layer between the business logic and storage tier. The Repository means that the storage representation doesn't leak into the logic layer.

hidden sky
#

Here's the actual Java one ๐Ÿ˜„

tribal tapir
#

Yeah. Didn't exist at the time. Yes... all that time ago.

waxen acornBOT
#

@versed forum

Your question has been closed due to inactivity.

If it was not resolved yet, click the button below to keep it
open, or feel free to create a new thread.

Note that usually the reason for nobody calling back is that your
question may have been not well asked and hence no one felt confident
enough answering.

When you reopen the thread, try to use your time to improve the quality
of the question by elaborating, providing details, context, all relevant code
snippets, any errors you are getting, concrete examples and perhaps also some
screenshots. Share your attempt, explain the expected results and compare
them to the current results.

Also try to make the information easily accessible by sharing code
or assignment descriptions directly on Discord, not behind a link or
PDF-file; provide some guidance for long code snippets and ensure
the code is well formatted and has syntax highlighting. Kindly read through
https://stackoverflow.com/help/how-to-ask for more.

With enough info, someone knows the answer for sure ๐Ÿ‘

versed forum
#

I didnโ€™t saw your message

#

Tysm

waxen acornBOT
#

@versed forum

Your question has been closed due to inactivity.

If it was not resolved yet, click the button below to keep it
open, or feel free to create a new thread.

Note that usually the reason for nobody calling back is that your
question may have been not well asked and hence no one felt confident
enough answering.

When you reopen the thread, try to use your time to improve the quality
of the question by elaborating, providing details, context, all relevant code
snippets, any errors you are getting, concrete examples and perhaps also some
screenshots. Share your attempt, explain the expected results and compare
them to the current results.

Also try to make the information easily accessible by sharing code
or assignment descriptions directly on Discord, not behind a link or
PDF-file; provide some guidance for long code snippets and ensure
the code is well formatted and has syntax highlighting. Kindly read through
https://stackoverflow.com/help/how-to-ask for more.

With enough info, someone knows the answer for sure ๐Ÿ‘

cerulean latch
tribal tapir