Tag Info

Hot answers tagged

5

If you are working solo. Here are the advices: Do as little low-level work as possible. Use as much library and tools as you possibly can including things you think you can easily code (don't do it, just use the library). Take the top-down approach. Only code things that you really need. When you see a problem in abstract term, search on google and use ...


4

I'd prefer the second approach, but with a better variable name. Don't repeat the logic for obtaining the manager (DRY). If this changes, you'll only need to change one place instead of three. Decouples the logic of operating on the manager from obtaining the manager. Extracting it to its own method is only a small step. Assuming you use a good name (not ...


3

tl;dr I suggest static methods, or even instance methods can be alright depending on the objects you're working with and how long lived they are as well as how stateful they are. Do not use properties for this. Properties should be as idempotent as possible (repeated access should return the same result constantly). If A property needs to execute logic to ...


1

Chained methods are awesome, but I almost always go for the variable approach. Other than what CodesInChaos already mentioned, it's just a lot quicker to interject some code and do some debugging / error handling. For example, in your code it would probably make sense to check if you've actually instantiated the Entity Manager before you start using it: ...



Only top voted, non community-wiki answers of a minimum length are eligible