So I made this method to set parameters from a text file:
def set_params(self, params, previous_response=None):
if len(params) > 0:
param_value_list = params.split('&')
self.params = {
param_value.split()[0]: json.loads(previous_response.decode())[...
@Zak You're welcome. You are free to vote any way you like, but if you are downvoting based on his readability compared to yours, make sure it is of equal quality or worst than the question. Different people see things differently.
It's not just the readability, I can't think (and I'm trying) of a single aspect of his code that is an improvement over mine. Except it's much shorter (because it doesn't do a lot of things it should).
So. His code goes Put sheet1 data in array (using hardcoded references), put sheet2 data in array. Match lists and print each match to the worksheet individually.
mine does all of that, in almost exactly the same way
except mine is extracted into methods
does not use hardcoded references
and only prints to the 3rd worksheet once, instead of 700 times
and also does some important data validation / formatting stuff
Basically what I'm saying is that his answer offers an implementation that doesn't do any single part of the process better than the equivalent part in my code, and also employs several bad coding practices (E.G. hard coded references) which mine does not.
it's not bad, it just doesn't provide, IMO, anything that would be useful as a way to improve the question as it stands
I'm having a little bit of trouble following it through without comments, but from what I understand you might e better off using a Microsoft query to 'join' on the "primary key" - you can take a look at this answer on superuser.
Otherwise, it seems, to me, that your process is doing a lot more ...
I fully believe that he's written an answer which he feels is useful (and something I easily might've written just a week or 2 ago) but is not actually good code
and I certainly don't want to downvote someone who's trying to help without providing an explanation on why I don't think their answer is a good one
@RubberDuck it's not about the IoC framework.. it's about DI. A small project can totally go with poor man's DI, but that entails a composition root and no newing up of dependencies in constructors. OP had 2 constructors there, one of them was never called in the app - the 2nd ctor was only there for testing - that's the smelly part :-)
@Mat'sMug I disagree with that. Without an IoC, having a composition root makes your code an awful mess. That ctor isn't solely for testing purposes. You can still use it if you decide to implement a second IFooBar class. The default ctor is simply a convenience method. It would have zero impact on moving to an IoC later.
@RubberDuck you're seeing things from a legacy app POV. From a DI POV, having 2 constructors makes no sense, one of them is not in use. If the composition root is the only place things get new'd up, then your code is no more of a bloody mess than what it would be with an IoC container. In fact, newing things up at the composition root is pretty much the only way introducing an IoC container will have zero impact on your code later on...
> Script: an automated series of instructions carried out in a specific order. Program: a series of coded software instructions to control the operation of a computer or other machine.
I've done poor man's DI for a small console app recently at work; the code is no different from what it would be if I added a reference to Ninject or any other IoC framework.
Any time you see things like "Size", "Gender", and "Home" in the same class, yes, you've gone overboard. This class violates a number of object-oriented design principles. You want reusable logic that keeps flexibility to throw your monsters like rocks and cast spells on your rocks that turn th...
I've been reading a lot about entity components and systems and have thought that the idea of an entity just being an ID is quite interesting.
However I don't know how this completely works with the components aspect or the systems aspect. A component is just a data object managed by some relev...
It depends on how you use it exactly but by using [Flags] (or just using 2^x values), you would turn that into an unsupported result. Instead of a random actual value
I'm designing a Factory in C++ with raw pointers, but I'd like to use smart pointers when possible as is recommended with the Factory pattern in newer C++. Unfortunately my compiler is a bit old (gcc 4.4.6) and not all of the features of C++11 (let alone C++0x) are available to me.
I cannot use ...
In this program there is a single remote server which performs miscellaneous work. Because there is only one server, it seems like a singleton pattern could fit well.
The problem that a distributed program introduces is that every client will have its own version of a static variable. Therefore...