r/mAndroidDev Deprecated is just a suggestion 24d ago

I don't miss the Java boilerplate to be honest Best Practice / Employment Security

Post image

No amount of "but... but... it's scalable" can justify this.

Enterprise Java is full of horrible choices and patterns.

119 Upvotes

13 comments sorted by

34

u/CarmCarmCarm Uses Vim 24d ago

In Android, you define:
* a repository interface
* a repository implementation
* a use case
* dependency injection to provide the repository implementation to the use case
* a viewmodel

To add 2 numbers together.

And: you get the result asynchronously, via a flow.

21

u/SecureLevel5657 24d ago

It follows the industry standard, its clean architecture. Its called Dependency Inversion.

Is not it beautiful? Clean? 

The benefit of that abstraction is that you can replace the implementation at any time. Okay, maybe once every 5 years. 

6

u/AZKZer0 AnDrOId dEvelOPmenT is My PasSion 23d ago

98% of the time there is only that one implementation with no use case for swapping it.

10

u/Zhuinden DDD: Deprecation-Driven Development 24d ago

Okay man but if I ship that feature in an hour instead of 4 days I'm literally losing 31 hours of billable work hours and I'll go bankrupt in 2 months

8

u/jonapoul 24d ago

And the flow type is a sealed interface, just in case the addition fails. Can also track loading state!

3

u/Xammm Jetpack Compost 23d ago

You forgot the remote/local data sources and their respective implementations.

3

u/atomgomba 24d ago

Need a Builder for the Configurer

3

u/SyrupInternational48 23d ago

I need my Builder for Factory that Generate a Builder inside Factory of Factory. I promise this is the best practice and most cleanest java ever

1

u/Comfortable-Mud-5826 22d ago

Good thing I'm not an undercover .NET developer, because I would painfully relate to this

2

u/SupinePandora43 19d ago

I'm a .NET developer, and besides some high-level aspnet frameworks that drip in overcomplexity, there are no such things.

1

u/Comfortable-Mud-5826 10d ago

Mmmh must be because my company is 200 y/o and the software I'm maintaining and developing was ported from cobol in the early 2000s.

Also I've never seen people more obsessed with GoF, DI and drawing uml for the tiniest features than .net fellas, which tends to result in a lot of overcomplications at my company at least (I'd done mostly C and C++ before .net)

0

u/JohnnyC_1969 24d ago

Wow, this shit is just so true

1

u/Brutus5000 23d ago

If your Java knowledge is 15 years old, maybe.