@Caridorc It's useful for the aircon to be able to deal with heat from more than one source. Not useful for the wheel to know anything about the aircon.
@Caridorc You're SO right. That's because I had no idea about something useful to show. :p Plus it somehow helps to see it in a simpler way. But I agree that showing a useful example also helps, in a different way
@DanLyons Well, it would have implemented the interface. I'm not sure I see the difference. Although yeah, in this example an interface might have been a better choice
Styling Nitpicks
private ICharacter _Personaje;
I like the underscore prefix for private fields. I like it, because I don't like plain camelCase fields for two reasons:
They look just like parameters and local variables
Disambiguating them from parameters/locals involves sprinkling redunda...
var village = new VillageBuilder()
.Building(new SmallHouse())
.Building(new SmallHouse())
.Building(new LargeHouse())
.Building(new ArmorShop())
.Building(new WeaponShop())
.Building(new Inn())
.Villager(new WomanInRed())
.Villager(new MadScientist())
.Villager(new PossessedChild())
.Build();
> The interface for a Village doesn't know how many Building or Villager it's going to have (nor what actual type they might be) - the builder pattern is useful here, because you can build villages with completely different features using the exact same builder code, and the Build method could be called at any given point, the village object would always be in a valid state.
The opening sentence of an answer I received in my previous post snowballed, and led to completely ditching the previous approach. Mocking my IDE with a MockFactory worked ok, ...for some values of "ok" - the more components needed to be involved, the messier the setup code was getting.
So inste...
@Mat'sMug I tried writing one but it fell apart under its own complexity. There is so much in there (special condition (poison, sleep, paralisis), critical hits, damage calculation formula, effectiveness ...
@Mat'sMug Why the Village doesn't simply have a list of buildings and of villagers where I could add? Unless there's something I don't get. Though the syntax is cool
I tried to calculate the following problem by brute force using R (under the assumption that a single pair of parenthesis would suffice).
Make 10 from the numbers 1, 1, 5, 8. You can use the operations + – *
/ (). You have to use all the numbers, and use each number exactly
once. The ope...
Because of the coupling with the VBIDE API (the extensibility library for the VBA IDE), unit testing the rubberduck refactorings, inspections and quick-fixes has been pretty much impossible, at least until a MockFactory was implemented, to do things like this:
internal static Mock<CodeModule> Cr...
When 'while True:' this code not work ?
when remove "while.." is correct
please help
import threading
import Queue
import time
def stringFunction(out_queue):
while True:
my_str = "1111111111"
out_queue.put(my_str)
time.sleep(1)
if __name__ == "__main__":
my_q...
I am delving into trying to write some javascript code.
I understand the basics, (the very basics...) enough that I have been able to write the following and it works.
however, my knowledge doesn't stretch enough to be able to work out if this was the "best" way to write what I am trying to ac...
Also, one thing that intriged me was that at the end of it, the stderr and stdout are still separate, and you can do pipe-redirection still on them individually.
http://www.commitstrip.com/en/2015/09/22/software-worth-billions/ CommitStrip - Blog relating the daily life of web agencies developers Software worth billions… CommitStrip 1442943203
@Mast Well, until then I hardcoded it - and I actually even wrote a 2nd version which is specific to one usecase which uses such hardcoded values, just to save some typing.
Not worth any big note though, it's almost like an alias
@Mat'sMug About the pokemon OO, I am writing it now, and it is really really hard. I have written 100 lines (no docs no tests) and I am just barely starting to scratch the surface. The Pokemon creators were genius
Would this match the Code Review site better, or not? — Numeri23 secs ago
@Numeri Sadly not. Code Review is for working code. Considering the compilation error it wouldn't fit! (Though the format of this answer does kinda fit in CR) — TopinFrassi46 secs ago
@TopinFrassi OK, just checking. I was wondering what Code Review was looking for in questions... Thanks! — Numeri36 secs ago
I know that this code would look a lot better if I made it so that checking the current prices against the open prices were in a function so I wouldn't have to re-write it for every stock I want to check, but I'm not sure how to get started on doing that properly. Do any of you have some tips to ...
@hjpotter92 not to be nitpicky, but "too broad" or "unclear what you're asking" would be better. Being on-topic elsewhere doesn't make a question off-topic here. Cheers! — Mat's Mug37 secs ago
I'm being careful now.. I accidentally got a 18K SO user to rage-quit with such comments.
A mouse with the correct software could pretend to be a keyboard and send keystrokes to download and run software using common keyboard shortcuts. — Joeyesterday
So this is a (fairly) simple IRC bot. The whole idea of it was similar to Duga, except for an IRC server instead.
The bot takes messages from a SQL table and posts them in the IRC server.
It supports a few (basic) commands which are sent as private messages to the user who requested the command...
how do i mock restTemplate.postForObject method ?
my code
//i have just mentioned the syntax.
String response= restTemplate.postForObject( URI, jsonObject, String.class) ;
I'm voting to close this question as off-topic because "how to improve this code" belongs on CodeReview.SE; StackOverflow deals with factual problems. — MSalters35 secs ago
below is my code I need to shorten it by using lists and for loops: I have had a go but keep on getting error message invalid literal any tips Help is very much appreciated. I am very new to python in general and lists
import random
total = 0
sixes = 0
fives = 0
fours = 0
threes = 0
twos = 0
on...
If you're looking for people to comment and give feedback on your code,rather than asking for help with something, I'd suggest that you move this question to the code review stack exchange site codereview.stackexchange.com — o0rebelious0o34 secs ago
below is my code I need to shorten it by using lists and for loops instead of all the variables: I have had a go but keep on the same message outputted several times and then also doesn't seem to work:
import random
total = 0
sixes = 0
fives = 0
fours = 0
threes = 0
twos = 0
ones = 0
limit = 50
...
I would like to properly raise an error if self._header was not created when I initialize a NewFile object.
This is working now, but perhaps there is more formal way of catching the error below:
class NewFile(object):
""" Docstring """
def __init__(self, filename):
self.localdi...
Also, @Mat'sMug there is (somewhere, I don't remember where) a class in .NET that you can specify a string for the algorithm to be used. I'd rather use my enum and implement them explicitly.
Now, I wonder what the HashAlgorithm enum will look like in the XML.
Problem
The strategy pattern is used to solve problems that might (or is foreseen they might) be implemented or solved by different strategies and that possess a clearly defined interface for such cases. Each strategy is perfectly valid on its own with some of the strategies being preferable in ...
I would like to properly raise an error if self._header was not created when I initialize a NewFile object.
This is working now, but perhaps there is more formal way of catching the error below:
class NewFile(object):
""" Docstring """
def __init__(self, filename):
self.localdi...
@RubberDuck so far it is a PITA. but I think it may have something to do with the fact that I am at work, and probably behind some fun firewalls that are restricting me from doing what I want....