How could anyone successfully create a new competing product once the majority of the market uses the cheap Netflix+Hulu-only package, locking them out from any potential competitors?
90 karma · joined May 17, 2012
How could anyone successfully create a new competing product once the majority of the market uses the cheap Netflix+Hulu-only package, locking them out from any potential competitors?
The advantage is that, as you're writing and embedding actual SQL, you can take advantage of any database-vendor-specific extensions to SQL, plus you can easily run, debug and test such SQL from another tool. Having full control over the actual SQL also means you don't risk potentially horribly inefficiently generated SQL, or risk running into unexpected N+1 scenarios. At the same time, you don't have to deal with JDBC and instead get a DAO layer that uses strongly typed objects.
Of course the disadvantage is that you lose portability; moving for instance a MyBatis/SqlServer app to Oracle will mean verifying, testing and potentially rewriting every single SQL statement in your app. If you're willing to accept that risk though, MyBatis is a great lightweight library to manage your database access layer.
Due to backwards compatibility concerns, no existing Java APIs that may currently return null can ever be changed to return Optionals instead, so nulls need to be dealt with regardless. Also, there's technically nothing stopping an Optional value from actually being null itself, or from developers calling Optional.get() without checking isPresent(), just like they might currently use a reference without checking for null.
I personally really wish jsr305 had been adopted in Java8, and their existing APIs retrofitted with these annotations.
http://www.oracle.com/technetwork/articles/java/java8-option... describes Optional, and compares it to how in Groovy, the safe navigation and elvis operators allow you to write code like this:
String version = computer?.getSoundcard()?.getUSB()?.getVersion() ?: "UNKNOWN";
With Java 8 Optionals, this instead becomes: String version = computer.flatMap(Computer::getSoundcard)
.flatMap(Soundcard::getUSB)
.map(USB::getVersion)
.orElse("UNKNOWN");
which is not only much longer and arguably uglier, but also forces developers to suddenly have to worry about applying lambdas using flatmap vs map, where conceptually you're really just dealing with method calls.New languages like Kotlin solve this much better in my opinion by introducing nullable vs nonnullable types. While Java can unfortunately never adopt this due to backwards compatibility issues, @Nullable and @Nonnull will do most of the time, and hopefully we'll see operators like ?. and ?: in future versions of Java.
I think the difference between his categorization of "Good programmers" and its subcategory of "Really good programmers" is the more interesting one though. Too many programmers seem to lack (or have lost) that drive to continually improve themselves, having become content with treating programming as nothing more than a 9-to-5 job during which they do little more than apply past knowledge. Like the article states, doing this puts them "at risk of slipping into the lower grouping by letting their skills atrophy".
The "Really good programmers" on the other hand are the ones with drive, with motivation; the ones that at least aspire for greatness even if they might stall out at merely being "very good". Every great programmer was once just a "Really good programmer", but you can't go from good to great without that passion.
In integration tests you should indeed run as close to real data as possible and execute your system's entire stack, including database calls. Unit tests on the other hand should be used to test small decoupled parts of the codebase.
If you have a class that implements certain business logic against data that would normally be retrieved from a database, a unit test using mocks can test this business logic in isolation, feeding a variety of data through the method to test a large number of scenarios and edge cases.
Speeding up this kind of testing is definitely important; test suites using mocks that can run in seconds can be executed after most changes to give immediate feedback to developers, whereas integration-type tests that might take an hour or more would slow down development too much to do this.
Integration tests are important as well, and should be run possibly nightly or at least prior to any release. They cannot be used to give the kind of immediate feedback that truly decoupled unit tests give though.