A lot of your questions seem to have a "functional programming" tendency to them. I write in C# everyday, but I try to write like a functional programmer as much as possible until the solution stops feeling natural to the language you're writing in. So I'll express some possibilities, but leave it to doyou to decide how far to go.
You most certainly can do this, but will it benefit you.? A funtionalfunctional programmer would be very inclined to have not just a value, but a type for each number. However, doing this in javaJava isn't cheap or what people expect. If you have an enum, you can get rid of some of your defensive programming checks. Doing that would probably be worth it.
I'm not sure what the inhertanceinheritance possibilities are for this class. A functional programmer would write the functionality and it would all be generally available. Inheritance puts a wierdweird twist on this. If you have real plans for it to be inherited, then condierconsider whether or not those classes will need to know about it at all. If you don;tdon't have any immediate inhertanceinheritance scenarios, I wouldn;twouldn't worry about it for now.
Again, a functional programmer would say abolutelyabsolutely return a new copy. In javaJava, you don't get the same language benefits that make this cheap or even worth it sometimes. So... you can, but it'll cost you code and complexity in javaJava.
Naming is the hardest part of programming most of the time. I would say there's a long one or two in here, but they seem to make a lot of sense so I'd be inclined to leave them. Method size is a good thing to be aware of. You should think about it in terms of how many things is my method doing. Generally speaking, methods that do fewrefewer things are better and are usually short. Long methods are a code smell, but not a hard-fast rule.
I've hammered away at the function nature of your questions only because it would seem you have good tendencies towards that kind of thinking. I'm a C# / F# programmer by trade. You shoudlshould consider learning Scala perhaps. You'd probably enjoy it.
A lot of your questions seem to have a "functional programming" tendency to them. I write in C# everyday, but I try to write like a functional programmer as much as possible until the solution stops feeling natural to the language you're writing in. So I'll express some possibilities, but leave to do decide how far to go.
You most certainly can do this, but will it benefit you. A funtional programmer would be very inclined to have not just a value, but a type for each number. However, doing this in java isn't cheap or what people expect. If you have an enum, you can get rid of some of your defensive programming checks. Doing that would probably be worth it.
I'm not sure what the inhertance possibilities are for this class. A functional programmer would write the functionality and it would all be generally available. Inheritance puts a wierd twist on this. If you have real plans for it to be inherited, then condier whether or not those classes will need to know about it at all. If you don;t have any immediate inhertance scenarios, I wouldn;t worry about it for now.
Again, a functional programmer would say abolutely return a new copy. In java, you don't get the same language benefits that make this cheap or even worth it sometimes. So... you can, but it'll cost you code and complexity in java.
Naming is the hardest part of programming most of the time. I would say there's a long one or two in here, but they seem to make a lot of sense so I'd be inclined to leave them. Method size is a good thing to be aware of. You should think about it in terms of how many things is my method doing. Generally speaking, methods that do fewre things are better and are usually short. Long methods are a code smell, but not a hard-fast rule.
I've hammered away at the function nature of your questions only because it would seem you have good tendencies towards that kind of thinking. I'm a C# / F# programmer by trade. You shoudl consider learning Scala perhaps. You'd probably enjoy it.
A lot of your questions seem to have a "functional programming" tendency to them. I write in C# everyday, but I try to write like a functional programmer as much as possible until the solution stops feeling natural to the language you're writing in. So I'll express some possibilities, but leave it to you to decide how far to go.
You most certainly can do this, but will it benefit you? A functional programmer would be very inclined to have not just a value, but a type for each number. However, doing this in Java isn't cheap or what people expect. If you have an enum, you can get rid of some of your defensive programming checks. Doing that would probably be worth it.
I'm not sure what the inheritance possibilities are for this class. A functional programmer would write the functionality and it would all be generally available. Inheritance puts a weird twist on this. If you have real plans for it to be inherited, then consider whether or not those classes will need to know about it at all. If you don't have any immediate inheritance scenarios, I wouldn't worry about it for now.
Again, a functional programmer would say absolutely return a new copy. In Java, you don't get the same language benefits that make this cheap or even worth it sometimes. So... you can, but it'll cost you code and complexity in Java.
Naming is the hardest part of programming most of the time. I would say there's a long one or two in here, but they seem to make a lot of sense so I'd be inclined to leave them. Method size is a good thing to be aware of. You should think about it in terms of how many things is my method doing. Generally speaking, methods that do fewer things are better and are usually short. Long methods are a code smell, but not a hard-fast rule.
I've hammered away at the function nature of your questions only because it would seem you have good tendencies towards that kind of thinking. I'm a C# / F# programmer by trade. You should consider learning Scala perhaps. You'd probably enjoy it.
A lot of your questions seem to have a "functional programming" tendency to them. I write in C# everyday, but I try to write like a functional programmer as much as possible until the solution stops feeling natural to the language you're writing in. So I'll express some possibilities, but leave to do decide how far to go.
Should BLANK be private static inside the BinaryPuzzle class? Or would it be better if I had an Enum for BLANK, ONE, and ZERO?
You most certainly can do this, but will it benefit you. A funtional programmer would be very inclined to have not just a value, but a type for each number. However, doing this in java isn't cheap or what people expect. If you have an enum, you can get rid of some of your defensive programming checks. Doing that would probably be worth it.
Is the name values[][] a good name? Why not boardValues or board?
It's a private variable, so it's not hugely concerning that it spell itself out exactly. I'm a firm believer that if your variable or member needs a long name, your class or function is probably trying to do too many things. Short names can be great.
Say I make a jar of this and someone would use this class, he will always have to extend this class if he wants to get the values[][] is that too strict?
I'm not sure what the inhertance possibilities are for this class. A functional programmer would write the functionality and it would all be generally available. Inheritance puts a wierd twist on this. If you have real plans for it to be inherited, then condier whether or not those classes will need to know about it at all. If you don;t have any immediate inhertance scenarios, I wouldn;t worry about it for now.
Should my solve() method be static? It is stateless, but if I make it static I can't override any methods.
There's nothing more testable than a stateless static function. It's simply the best and what functional programming puts in the forefront.
Should solve() clone/copy BinaryPuzzle and return a new one? Or is the fact that it returns a boolean enough to imply that the BinaryPuzzle given as param is modified?
Again, a functional programmer would say abolutely return a new copy. In java, you don't get the same language benefits that make this cheap or even worth it sometimes. So... you can, but it'll cost you code and complexity in java.
solve() actually only uses the values[][] from BinaryPuzzle, should that be the param instead?
I would vote for that. A wrapper type of BoardValues that carries that double array would be very effective.
Are my helper methods good with regards to naming and lenght? I tried to think about good names and make them smaller about 7 lines, but it is hard!
Naming is the hardest part of programming most of the time. I would say there's a long one or two in here, but they seem to make a lot of sense so I'd be inclined to leave them. Method size is a good thing to be aware of. You should think about it in terms of how many things is my method doing. Generally speaking, methods that do fewre things are better and are usually short. Long methods are a code smell, but not a hard-fast rule.
As you can see some methods have the default modifier instead of private, because they are less trivial and I wanted to write tests for them. Performing TDD and testing only public methods (solve() in this case) seems bad, so much functionality is in solve(). But making my methods that I want to test default seems weird, I have never seen someone do that. The classes that I left private are hard to test or are trivial.
When I write private methods, I do not test them individually. I have on occasion made a function internal to be able to test it. But I think a better solution is to move that function to a static class and make it public (if possible). This is another benefit of a function style of programming.
I had a hard time thinking about a good name for my HashMap inside solve() method and the mapAllMatchingBinaryNumbersToEachBinaryNumberInsideBinaryPuzzleBasedOnSetValues is downright rediculous. Any suggestions?
I think the context is small. A large name shouldn't be required. That function has 5 executable lines, if understanding a short name is too difficult under those conditions, the method should be split up.
I've hammered away at the function nature of your questions only because it would seem you have good tendencies towards that kind of thinking. I'm a C# / F# programmer by trade. You shoudl consider learning Scala perhaps. You'd probably enjoy it.