Tag Info

New answers tagged

0

As @Machado said, the easiest way to do it is to avoid it and doing all your processing in your main java. However, it is still possible to have to code base with similar code without repeating your self by generating the code for both of code base. For example using cog enable to generate the three snippets from a common definition snippet 1: /*[[[cog ...


0

Your findBy methods don't couple you to the database structure, they couple you to business requirements. Personally, I don't mind repositories that have multiple findBy methods, as long as they are clean and neat. For example: User findById(string id); User findByEmail(string email); User findByUserName(string userName); To me seems like a clean ...


3

You say that the example is artificial, so I don't know if what I'm saying here suits your actual situation, but my answer is - use an ORM (Object-relational mapping) layer to define the structure and querying/manipulation of your database. That way you have no duplicated logic, since everything will be defined in the models. For example, using the Django ...


1

I've written a silly example to explain an idea: class BinaryIntegerOperation { public int Execute(string operation, int operand1, int operand2) { var split = operation.Split(':'); var opCode = split[0]; if (opCode == "MULTIPLY") { var args = split[1].Split(','); var result = ...


11

As lxrec pointed out, it'll vary from codebase to codebase. Some applications will allow you to put those kind of business logic into SQL Functions and/or queries and allow you to run those anytime you need to show those values to the user. Sometimes it may seem stupid, but it's better to code for correctness than performance as a primary objective. In ...


2

DELIVER This is your priority. This is all they care about. This is what you've got to do. If you get to deliver something that you feel has a sense of quality to it, you'll fell better and work better, and see a future for yourself in that company. But you have to be realistic about time constraints. Do you have first hand experience of refactorings? Can ...


5

We're the wrong people to ask. You're writing this code for the company; essentially it is your customer. Someone in that company knows who's going to work on it next; someone has an idea of whether more features or more maintainable code have greater value for them. You are your customer, too, in some ways - what do you want to get out of this? Pride? ...


2

This sort of thing can always be done with an IDE. I am not familiar with an IDE that supports this exact formatting, but I know that most modern IDEs have highly customizable settings for formatting code. As a Java programmer using Eclipse, I have it set so that I can type Ctrl+A(select all) Ctrl+Shift+F(code-format) and it will prettify all my Java code ...



Top 50 recent answers are included