@nhgrif Suggestion for a commandment: "Tell, don't ask". This is related to Dependency Injection and other things, and is essentially the approach to get rid of that bloody singleton pattern. I've mentioned the concept of "Tell, don't ask" a couple of times in my CR answers.
Using a static variable will have the same effect as using a singleton!
Imagine if you had two instances of ProductsCache:
var a: ProductsCache = new ProductsCache();
var b: ProductsCache = new ProductsCache();
a.products = someArrayCollection;
b.products = anotherArrayCollection;
Now, becaus...
@MadaraUchiha I can agree with that. Ask directly what it needs: this.specialNumber asking for something that will allow you to get what you need: this.specialObject.getSpecialSomething().getSpecialNumber()
Simon, thanks for the comment. The Tell, don't ask principle, it actually makes sense, never thought about it before. It will certainly improve my future code — Wayne LinksFeb 14 '14 at 22:07
@SimonAndréForsberg Can you elaborate on "Tell, don't ask" and exactly how you apply it to programming? I'm trying to assure that the commandments have as few exceptions (or none at all) in my mind as possible.
@SimonAndréForsberg While in general, I agree with "Tell, Don't Ask", I think... I also think it has too many exceptions and seems to only apply to OOP.
Or maybe it doesn't necessarily have too many exceptions if you only apply it to OOP... but then you're only applying it to OOP... and if I wanted commandments that applied only to specific types of programming, I've got some others that I could've used.
So, consider this though... I've been doing a lot of GPS programming lately. All of Apple's CoreLocation library pretty well deals with a CLLocation object.
CLLocation contains a lot of information, and at the end of the day, it's just far easier to pass that around. But when I want to put a pin on the map? I need to get the CLLocation's coordinate property (a CLLocationCoordinate2D)
So following "Tell, Don't Ask", if I have a method that plots a start, mid, and end point on a map, I'd need to do this:
@JohnSnow At work I am the lone developer for a single-page web app written in Scala. It's used by the archive operators to manage incoming and outgoing data for the Hubble and Kepler space telescopes.
@JohnSnow, you should avoid discussions of the personal, opinion-based sort while offiicial site business (eg: OOP discussion) is happening; We have The Nth Monitor for that kinda conversation
I guess this concept is just too vague for me to understand. I think I largely agree with in general, but I don't think I understand it solidly enough to pass it forward to others as a commandment.
> If a function be advertised to return an error code in the event of difficulties, thou shalt check for that code, yea, even though the checks triple the size of thy code and produce aches in thy typing fingers, for if thou thinkest ``it cannot happen to me'', the gods shall surely punish thee for thy arrogance.
Someone on the Internet is writing Monty Python programming commandments.
> Thou shalt study thy libraries and strive not to reinvent them without cause, that thy code may be short and readable and thy days pleasant and productive.
The question I refer to is this one. It has been cross-posted from StackOverflow, it hasn't received any review yet but it has been edited on SO but not on CR. The edits made (indentation correction) are minor and would only affect the comments on CR, but since no answer has been posted yet, it w...
I have a large text file (>1GB), it would be crazy to go through all of it manually. Someone suggested Python - I am new to it but am stuck and need some help. There are 15 columns with different headings and I need to extract certain dates from it. How do i go about doing this?
Thanks
@nhgrif - does the check-mark on the beginner-tag answer meta.codereview.stackexchange.com/a/5760/31503 mean that you now agree that the beginner tag should stay, and has a use, or is there some subtlety that I am missing?
tl;dr: Can we have source-code-quality synonymed to code-quality please?
Facts:
code-quality 310 questions - Wiki:
Code quality is a measure of how well a set of code balances qualities of maintainability, performance, and style.
source-code-quality 36 questions - Wiki:
Source Code ...
I was interested in the codegolf challange about simple text. The spec is:
Write a function that from a text returns the non-common words.
I assumed non clean input so I cleaned it before proceding.
The 'foo' 'barz' list is for easier testing, you may uncomment the line to read from a file...
I have few confusions about to write code (Java) - what I need to follow -
Below is my code - Based on the following code, I need some clarifications -
import java.util.Scanner;
public class NameAbbreviation {
private static String fullName;
private static Scanner nameInput;
public NameAb...
@Vogel612 I just got confused when nhgrif accepted an answer that was so obviously different from his stated position on the tag. That's all. It appears he's accepted the answer despite it being the opposite, and he's still emphatically against it. The difference between his actions, and words needed clarification. That's all.
@rolfl The accepted answer is the only one that actually admits that it's a meta tag and attempts to explain its existence in spite of its meta-ness, rather than trying to argue its non-metaness like everyone else still continues to do. It's the only answer with any value.
I am teaching a python class to some high school seniors. I was thinking of doing an "oracle" game where the computer would come up with a number, and the player would guess it. These are brand new coders, and I'll teach them what they need to know to get there, but is this a good first project? ...
@Vogel612 it is an attempt to create an example of something that fits the rules of the process, but is inappropriate..... so, as an exercise for readers: why is my community ad inappropriate (or is it OK)?
@Vogel612 - I don't want Code Review ads to promote anyone's personal blog.... it does not fit with "community promotion" ... but, we have a candidate that has met the 6-vote threshold, and thus Code Review, as a community, is encouraging the promotion of personal blogs.... which is... odd, and uncomfortable.
So i'm developing an algorithm that takes structured light patterns to determine 3d properties of objects. This class builds the structured light objects. It creates a buffered image, and based upon initialization parameters and the needed iteration step, manipulates the image to form a structu...
Community ads will eventually be enabled on this site (6-8 weeks I wager).
The system works by community voting. Anyone from anywhere can come to our meta and post an ad for anything - it's our job to vote it up or down and decide if we want to see that ad displayed on our main site.
What kind ...
Community ads will eventually be enabled on this site (6-8 weeks I wager).
The system works by community voting. Anyone from anywhere can come to our meta and post an ad for anything - it's our job to vote it up or down and decide if we want to see that ad displayed on our main site.
What kind ...
Community ads will eventually be enabled on this site (6-8 weeks I wager).
The system works by community voting. Anyone from anywhere can come to our meta and post an ad for anything - it's our job to vote it up or down and decide if we want to see that ad displayed on our main site.
What kind ...
@Mat'sMug @ others - Would submitting an ad for a blog from a writer who's not affiliated with CR at all, and the blog as a pretty broad approach, for example Guillaume Laforge's blog about the Java & Groovy ecosystem, be OK?
It's up to the community. we are having a discussion about how people should vote. This didn't start because I posted my ad. It started because someone isn't happy my ad crossed the threshold.
@nhgrif and why you that be about you? I made that thread because we're obviously having a chat discussion about community ads, from which I believe general posting guidelines would stem - and those belong on meta, not in chat.
Of course, but everyone may not want to. Maybe some people in here would rather talk of something else, but with a big conversation also happening in the room, it is difficult.
Correct me if wrong, but it more looks like the idea seems to be that random conversations and oneliners (baiting actual conversations) happen around here, and as soon as people actually get into a conversation (and share interesting stuff), they need to move out
I'm currently setting up some dev-ops stuff at work, trying to decide between gitolite and gerrit. Has anyone here had experience with code reviewing workflows in a professional environment?
Take a look at it from the other side... There's 10 users here watching righ tnow, they might've been interested in the conversation, now you moved that conversation in order to do some business directly related to the site
This chat is not dead. It is just doin gwhat it does best - waiting for business to arrive, or spawning other interesting conversation that evolves to the point where it grows up and moves out.