Tag Info

New answers tagged

0

So, for me, this method does one thing. It retrieves (gets) ObjectOutputStream object as its name says No. You can't retrieve something that doesn't exist. Creating an object which didn't exist before and returning that object changes program state (possibly with other significant side effects). It's not a retrieval. Retrieval should be a safe, ...


0

As others have pointed out, your method does actually expose the fact that it is more than just a getter, since it publicizes the fact that it may throw an exception. So, you might as well make it clear in the name of the method that it works either as a getter or as a factory, otherwise someone using at it is bound to frown upon the fact that an ...


0

Yes, I think method name should describe side effects. For one thing, this example uses checked exception, which by itself reveals implementation details. Invocation of this method requires try/catch block anyway (for no reason, since it can be handled inside and throw NPE or return null, which wouldn't improve the situation, but at least make it cleaner on ...


4

Step 1 is of course make it so your method doesn't have side effects. But let's focus on the example. Yes, you should generally abstract what a function does from how it does it, but side effects are clearly still part of what the function is doing. By making them explicit in the name, you are making the code clearer about what is going on, leading to less ...


2

But you do care about it being created, because it can throw an IOException! In fact, the only time it can throw is the first time it's called. Every other time you'll need to put a pointless try/catch block (assuming this is Java) in the calling code for something that will never happen. I'd refactor this code to have an explicit stream creation method. ...


2

Object pointers are not primitives in the sense that strings or ints are. A PersonName* is not a Genus* and its not a ProductDecription*. Unsurprisingly, the equivalent to primitives for pointers is pointers to primitives. Adding an extra level of indirection won't change that either way.


0

I believe the are a anti pattern and frankly think they should be eliminated. But if you are in the unfortunate situation of working in a place where they are a standard Visual Studio offers an awesome tool to minimize the amount you would like to vomit everytime you see a region I Hate #Regions This plugin will max the font size of the regions really ...



Top 50 recent answers are included