6 ms·
It doesn't feel like it's enterprise enough to be realistic. class TwoBaconRashersInsideTwoSlicesOfBreadFactory { /* Make a sandwich *
by FuzzyDunlop 13y ago
It doesn't feel like it's enterprise enough to be realistic.
class TwoBaconRashersInsideTwoSlicesOfBreadFactory {
/* Make a sandwich
* <p>
* Construct a foodstuff consisting of two slices
* of bread with two slices of bacon.
* @return TwoBaconRashersInsideTwoSlicesOfBread a sandwich
*/
Public TwoBaconRashersInsideTwoSlicesOfBread getSandwich () {
BaconRasherFactory pig = new BaconRasherFactory();
BaconRasherInstance bacon1 = pig.getBaconRasher();
BaconRasherInstance bacon2 = pig.getBaconRasher();
SliceOfBreadFactory loaf = new SliceOfBreadFactory();
SliceOfBread bread1 = loaf.getSliceOfBread();
SliceOfBread bread2 = loaf.getSliceOfBread();
return new TwoBaconRashersInsideTwoSlicesOfBread(bread1, bacon1, bacon2, bread2);
}
Or something... trying to do Enterprise Java is hard.
- pjmlp 13y agoAny language has hard time being enterprise. That what the space station architects are there for.
- pkorzeniewski 13y agoNot enterprise enough, it doesn't implement any interfaces nor extends any generic classes, there also should be some try/catch blocks (what if the bacon isn't fried enough?) and of course several unit tests to guarantee the highest quality sandwich ;)
- JonnieCache 13y agoThere isn't even any XML. Not enterprise at all, by definition.
- phire 13y agoYeah, we should be able to define types of sandwiches in XML. What if someone wants a BLT?
- wting 13y agoYou can always use this gem for reference: https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition https://github.com/EnterpriseQualityCoding/FizzBuzzEnterpris...
- Uchikoma 13y agoLanguage bashing is what characterizes our industry. I have the dream that one day we will recognize languages as the tool they are and be mature enough to chose tools by utility and not by hype, hipness or pop culture and see there benefits and limitations.
- Bootvis 13y agoHe is not bashing Java per SE but a special kind of Java: Enterprise Java and IMO that deserves a bashing on general principle. Enterprise Java just never seems appropriate.
- Uchikoma 13y agoHe was bashing a programming language - you call it Enterprise Java - for laughs and karma, not seeing languages as tools you can use based on your judgement. I hope we once will grow beyond bashing. [Edit] And this is the highest voted comment on a thread about how cool GTA V is to include programming references and how deep their open world is.
- pjmlp 13y agoHN youngers of today like to bash Enterprise Java, whereas the old guys already have their share of scares from: Enterprise Clipper Enterprise C Enterprise C++ Enterprise Perl Enterprise TCL Enterprise insert language here You just need to let the enterprise architects loose...
- FuzzyDunlop 13y agoI'm probably young enough to have experienced Enterprise PHP, which by all accounts (at least when Symfony2 was just released) seemed like the love-child of Enterprise C++ and Enterprise Java.
- breckinloggins 13y agoI don't know if that pun was intentional, but if it was it's absolutely fantastic. So as to remain on topic: I agree with you but the other side of the coin is that Java the language can't seem to live down Java EE and its culture. It's trying, though. I give particular kudos to the Clojure and Scala communities for helping to rebrand the JVM as something awesome independent of Java. That helped me, at least, to realize that I shouldn't conflate the two in my head. The only stumbling block I have to get around in my head now when I think JVM is "JVM == long startup times", which is still kinda true but nowhere near as bad as it was.
- cgh 13y agoYour use of "new" implies those factories have no interfaces. Normally they would be injected.
- vezzy-fnord 13y agoMake the comment into Javadoc, add some more modifiers, increase the method names and I think you're well on your way.
- astral303 13y agoHmm... how about... @Service public class SandwichFactoryImpl implements SandwichFactory { @Autowired public EmptySandwichFactory emptySandwichFactory; @Autowired public FoodComponentFactoryFactory foodComponentFactoryFactory; @Override public Sandwich makeSandwich(Collection<FoodComponentDescription> foodComponentDescriptions) { Sandwich sandwich = emptySandwichFactory.newSandwich(); for (FoodComponentDescription foodComponentDescription : foodComponentDescriptions) { FoodComponentFactory foodFactory = foodComponentFactoryFactory.getFactory(foodComponentDescription.getType()); for (int i = 0; i < foodComponentDescription.getQuantity(); i++) { sandwich.addFood(foodFactory.create()); } } return sandwich; } public SandwichDTO makeMyFavoriteSandwich() { Collection<FoodComponentDescription> components = Lists.newArrayList(); components.add(new FoodComponentDescription(FoodType.BREAD, 1)); components.add(new FoodComponentDescription(FoodType.BACON, 2)); components.add(new FoodComponentDescription(FoodType.BREAD, 1)); return makeSandwich(components); } }
- FuzzyDunlop 13y agoThis is much more inspired. I sort of feel sympathetic, because of the potential mental anguish you were likely to have incurred while writing it.