问:
Scrum Board for a distributed team
I am looking for recommendations on a digital Scrum Board which can be shared over the internet. I imagine something like a big tablet on which you can draw and which remote users can access, too.

I dislike Scrum software because I think one major benefit of a Scrum Board is its physical presence. It should be hard to ignore.

The best solution would be two big tablets on which you can draw and which can be synchronized.

Has anyone got product recommendations for something like this? Or would you rather use a software?

Kind regards,
Falcon

答:
When we started our recent Scrum implementation, the team was located in the same office, but we wanted the capacity to be able to work in a distributed manor in case we had another earthquake here in Christchurch.

We settled on using a Trello to handle the backlog, and a Google Spreadsheet to mirror our physical board. This means that if anyone is working remotely, they have access to the User Story and Acceptance Criteria from Trello, and a view of the current state of the tasks from the spreadsheet.

The spreadsheet also produces the burn down for the sprint, and provides a lot of the stats that we examine during the Sprint Retrospective, so it's provided a lot of benefits.

Unfortunately we never went any further looking for an online visual representation of the board, since everyone was quite happy with the physical board. Trello is nice for moving tasks between To Be Done/Doing/Done, but it doesn't have the nice snow-plough effect that you get on a physical board.

We did look briefly at SeeNowDo, which is free, and "Looks" like a scrum board, and I've heard of other distributed teams using is successfully, so it might be worth checking out.

If you're interested, I've written a series of posts about our search for an online Scrum board, how we import a backlog into Trello, and back up our Trello boards into a Google Spreadsheet.

Title: Scrum Board for a distributed team


问:
Why does JSF automatically generate names for html components and can this be overridden?
I'm reading up on JSF. One thing that I noticed is that tags such as h:inputText and h:inputTextarea auto-generate a random name.

Is there any way to over-ride this?

答: The name and id for the rendered HTML are generated by the UIComponent.getClientId() method, so all you have to do is override that method. However, doing so is not recommended since it risks breaking the contract of the ID (which must be unique even when the same component is rendered multiple times), which would lead to very complex bugs.</p>

ContentLicense: CC BY-SA 3.0


问:
Design documents as part of Agile
At my workplace, we face a challenge in that "agile" too often has meant "vague requirements, bad acceptance criteria, good luck!"  We're trying to address that, as a general improvement effort.

So, as part of that, I am proposing that we generate design documents that, above and beyond the user story level, accurately reflect the outcome of preliminary investigations of the effect of a given feature within the system and including answers to questions that we have asked the business.

Is there an effective standard for this?

We currently face a situation where a new feature may impact multiple areas in our "big ball of mud" system, and estimates are starting to climb due to this technical debt.  Hopefully more thoughtful design processes can help.

答:
The Agile "mantra" is not to do without documentation entirely.

The Agile mantra is to prefer "Working software over comprehensive documentation". But note the bit at the bottom of the manifesto.

That is, while there is value in the items on the right, we value the items on the left more."

Uncle Bob has a good policy for documentation

Produce no document unless it's need is immediate and significant.

You're right that some people use Agile as an excuse for not producing documentation, but that's bad Agile. It's ignoring the bits that I've highlighted in the quotes above.

All that said, when you say 'we currently face a situation where a new feature may impact multiple areas in our "big ball of mud" system', if you're going to be Agile, you need to do something about this.

When you have your documentation, use it to modularise your code. That way you remove the long-term need to maintain the documentation (which won't happen) by removing the long-term need for the documentation.

ie. Make the need immediate and significant.

Title: Design documents as part of Agile


问:
What makes C developers so curious if "i++ == ++i"?
Just a random observation, it seems that on StackOverflow.com, there are questions about if "++i == i++". That question gets asked all the time though, I think I saw it asked about 6 or 7 times in the past 2 months.

I just wonder why C developers are so interested in it? The same concept/question exists for C# and Java devs as well, but I think I saw only one C# related question.

Is it because so many examples use ++i? Is it because there is some popular book or tutorial? Is it because C developers just love to cram as much as possible into a single line for 'efficiency'/'performance' and therefore encounter 'weird' constructs using the ++ operator more often?

答:
Two reasons.

The correct implementation of ++i is to increment i and then return it.
The correct implementation of i++ is to save the current value, increment i, and return the saved value.  Knowing these are not implemented as synonymns is important.

The question then becomes when does the compiler apply them while evaluating an expression, such as equality.

If the equality test is done first, then the pre- and post- increment operators, you're going to have to write different logic than if the left hand side (lhs) and the right hand side (rhs) are evaluated first, then the equality.

It's all about order of operations, and that in turn affects the code one writes.  And, not too surprisingly, not all languages are in agreement.

Basic tests list this allow developers to test to see if their assumptions are correct, as well as if the actual implementation matches the language specification.

This can have all kinds of impact when working with pointers, loops, or returning values.

ContentLicense: CC BY-SA 2.5


问:
Compilable modern alternatives to C/C++
I am considering writing a new software product. Performance will be critical, so I am wary of using an interpreted or language or one that uses a emulation layer (read java).

Which leads me to thinking of using C (or C++) however these are both rather long in the tooth. I haven't used either for a long time. I figured in the last 20 years someone has probably created something which is reasonably popular, nice to code in and compiled.

What more modern alternatives are there to C for writing high performance compiled code?

If C++ is a different beast than it was 15 years ago, I would consider it, I guess I had an assumption that it had some inherent problems.

Parallelisation would be important, but probably not across multiple machines.

答:
There is also Ada, which compiles to native code, and is portable across various platforms within the limits of its standard library. The language is alive and well, with the most recent language standard update currently underway (known as Ada 2012).

Quick summary for those unfamiliar with Ada:

Strongly-typed

Built-in support for concurrency

Object-oriented or procedural, depending on your requirements

Supported by GNU toolchain (GCC contains Ada frontend)

Excellent also for software development, i.e. when you need to directly interface with hardware

Supports generic programming (generic packages, procedures, functions)

Features support large-scale software development (packages, child packages, separate compilation, strict distinction between specification and implementation)

ContentLicense: CC BY-SA 4.0

Title: Compilable modern alternatives to C/C++


问:
Empirical evidence for choice of programming paradigm to address a problem
The C2 wiki has a discussion of Empirical Evidence for Object-Oriented Programming that basically concludes there is none beyond appeal to authority. This was last edited in 2008. Discussion here seems to bear this out: questions on whether OO is outdated, when functional programming is a bad choice and the advantages and disadvantages of AOP are all answered with contributors' opinions without reliance on evidence.

Of course, opinions of established and reputed practitioners are welcome and valuable things to have, but they're more plausible when they're consistent with experimental data. Does this evidence exist? I know that evidence-based software engineering is a thing, but can I practice it in this context? Specifically, if I have a particular problem P that I want to solve by writing software, does there exist a body of knowledge, studies and research that would let me see how the outcome of solving problems like P has depended on the choice of programming paradigm?

I know that which paradigm comes out as "the right answer" can depend on what metrics a particular study pays attention to, on what conditions the study holds constant or varies, and doubtless on other factors too. That doesn't affect my desire to find this information and critically appraise it.

It becomes clear that some people think I'm looking for a "turn the crank" solution - some sausage machine into which I put information about my problem and out of which comes a word like "functional" or "structured". This is not my intention. What I'm looking for is research into how - with a lot of caveats and assumptions that I'm not going into here but good literature on the matter would - certain properties of software vary depending on the problem and the choice of paradigm.

In other words: some people say "OO gives better flexibility" or "functional programs have fewer bugs" - (part of) what I'm asking for is the evidence of this. The rest is asking for evidence against this, or the assumptions under which these statements are true, or evidence showing that these considerations aren't important. There are plenty of opinions on why one paradigm is better than another; is there anything objective behind any of these?

答:
I do not believe this type of study exists.  One would believe it is not the programming paradigm that matters as much as the actual algorithm that is used.  For instance given any non-trivial system one that relies on small space algorithms verse one that relies on small time algorithms would generate different metrics.  The one that has the better time would most likely be deemed more valid, unless space is an issue then the inverse is true.  I find it similar to paving a road.  While the algorithm or recipe for making the materials is constant throughout all processes it would be possible one company thinks paving two lanes at once (one on each side of the road) is better than paving two lanes on the same side of the road at once.  At the end of the day it doesn't matter as the process of making the black top is still the same, the only difference is the approach.  Going back to programming, if you have a team of C developers, write the code in a procedural manner, if you have a team of Java developers write it in OO.  Do not get hung up on the paradigm so much as the implementation of the algorithm.   Because at the end of the day you can write Java like C and you can try to write C like Java.

UPDATE

To reply to the comment graham left me:

I assume by architecture you mean programming paradigm.  If you are going to use Clojure maybe you should hire a team of Clojure programmers.  However, based on a quick search Clojure is a Java based language it just so happens to be functional.  Given that information I would take the Java programmers (since technically they can just write Java and it will give you the same results) or look for functional programmers such as Haskell developers.  Now in terms of choosing what is best it is completely dependent on your team.  I would never have a team of relational database experts organize a cloud solution for me nor would I have a team of functional programmers build out an object orient solution for me.  You have to use the strengths of the team you have not the glorified vision you have in your head for what a team "should" be able to do.


问:
Usage of repository between EF model and code consumer
I have binary data in my database that I'll have to convert to bitmap at some point. I was thinking whether or not it's appropriate to use a repository and do it there. My consumer, which is a presentation layer, will use this repository. For example:

// This is a class I created for modeling the item as is.
public class RealItem
{
    public string Name { get; set; }
    public Bitmap Image { get; set; }
}

public abstract class BaseRepository
{
    //using Unity (http://unity.codeplex.com) to inject the dependancy of entity context.
    [Dependency]
    public Context { get; set; }
}

public calss ItemRepository : BaseRepository
{
    public List<Items> Select()
    {
        IEnumerable<Items> items = from item in Context.Items select item;
        List<RealItem> lst = new List<RealItem>();
        foreach(itm in items)
        {
            MemoryStream stream = new MemoryStream(itm.Image);
            Bitmap image = (Bitmap)Image.FromStream(stream);
            RealItem ritem = new RealItem{ Name=item.Name, Image=image };
            lst.Add(ritem);
        }

        return lst;
    }
}
```

<p>Is this a correct way to use the repository pattern? I'm learning this pattern and I've seen a lot of examples online that are using a repository but when I looked at their source code... for example:</p>

<pre class="lang-cs prettyprint-override"><code>public IQueryable<object> Select
{
    return from q in base.Context select q;
}
</code>```

as you can see no behavior is added to the system by their approach, so I was confused that maybe repository is something else and I got it all wrong. At the end there should be extra benifits of using them right?

答:
There are several potential benefits of a repository pattern, especially if you set it up as an interface that can easily use dependency injection.  I noticed in your example only the context is being injected, you might change it to allow the repository itself to be injected.

It can aid in unit testing the other layers by isolating the data access to allow you to easily mock the repository so that your unit tests are not dependent on the repository.

It can be used to enforce certain methods and consistency of access to your repository.  For example in a multi-tenancy application you may want to ensure that the Tenant Id is always passed rather than allowing direct access to the context to help enforce security.

It reduces duplication of code in your other layers.

It decouples the repository from your other layers so that the repository itself can be more easily changed at a later time.

Some of the same objectives can be met with a business logic service layer, it depends on the needs of your application.


答:
Different paradigms lead to different solutions. Which fit is 'best' depends largely upon:

the solution

the development team

the operational environment

I know of no such definitive study, and even if there was one I would not trust it.

That is the architect's job.

Replacing the architect's wisdom with the possibly irrelevant conclusions of a study is a recipe for disaster.

Note: a comment mentions deciding upon "the algorithm" and then choosing the language. Algorithms are the central structural mechanism for procedural languages. Object-oriented languages focus on classes and patterns of collaboration/communication. If you're convinced (as the architect) that an algorithm-centric solution is 'best', then stick with procedural or functional languages.

Addendum: not trusting studies is not 'superstition', it is common sense. Scientific experiments must be objective and repeatable. Software projects are highly subjective, but even worse they are unrepeatable experiments. You simply cannot implement a project X with team Y, measure the results, and then roll back time, erase memories, and re-do the same project with the same team. Information discovered or implied by studies may be useful to the architect, but it can never be definitive.

Title: Empirical evidence for choice of programming paradigm to address a problem

Body:
The C2 wiki has a discussion of Empirical Evidence for Object-Oriented Programming that basically concludes there is none beyond appeal to authority. This was last edited in 2008. Discussion here seems to bear this out: questions on whether OO is outdated, when functional programming is a bad choice and the advantages and disadvantages of AOP are all answered with contributors' opinions without reliance on evidence.

Of course, opinions of established and reputed practitioners are welcome and valuable things to have, but they're more plausible when they're consistent with experimental data. Does this evidence exist? I know that evidence-based software engineering is a thing, but can I practice it in this context? Specifically, if I have a particular problem P that I want to solve by writing software, does there exist a body of knowledge, studies and research that would let me see how the outcome of solving problems like P has depended on the choice of programming paradigm?

I know that which paradigm comes out as "the right answer" can depend on what metrics a particular study pays attention to, on what conditions the study holds constant or varies, and doubtless on other factors too. That doesn't affect my desire to find this information and critically appraise it.

It becomes clear that some people think I'm looking for a "turn the crank" solution - some sausage machine into which I put information about my problem and out of which comes a word like "functional" or "structured". This is not my intention. What I'm looking for is research into how - with a lot of caveats and assumptions that I'm not going into here but good literature on the matter would - certain properties of software vary depending on the problem and the choice of paradigm.

In other words: some people say "OO gives better flexibility" or "functional programs have fewer bugs" - (part of) what I'm asking for is the evidence of this. The rest is asking for evidence against this, or the assumptions under which these statements are true, or evidence showing that these considerations aren't important. There are plenty of opinions on why one paradigm is better than another; is there anything objective behind any of these?


问:
ReSharper's effect on coding interviews
Anyone who has used R# or CodeRush knows how fast you can put together simple constructs (and refactor complex ones) with a simple keyboard shortcut.  However, do these productivity plugins cause a false evaluation of ability during interviews?

Part of being a productive code writer (and making a good first impression in an interview) is writing good code - fast.

If I had two candidates:

Doesn't use plugins.  She thinks about the problem, sits down at a stock IDE at the interview PC that looks exactly like hers and types out the code in a minute or two, as usual.  Done.  Pass.

Uses plugins.  He thinks about the problem, sits down at a stock IDE at the interview PC and realizes "fe + tab" no longer writes a foreach loop automatically, and all the shortcuts are gone.  He then bumbles around the keyboard hitting his normal hotkeys and popping up strange windows and getting flustered.  It takes him 3 minutes to write what normally would take 30 seconds.  Done.  Looked like they didn't know their way around the IDE at times.  Must be new to this IDE and thus not had much experience with it or maybe the language.  Pass, but a 'meh' mark beside their name.

In your experience, how do you handle plugins during interviews as the interviewer or interviewee?  What are the best practices to getting what the candidate really knows?  There can be candidates who don't understand code, and use R# as a crutch.  There can also be candidates who know the code in and out and use R# because it's just plain faster than the built in VS or Eclipse templates.  Is it best to just not use an IDE at all?  Let them bring their own PC?  Others?

答:
That's one of the reasons I ask people to code at the whiteboard, not in the IDE. It levels the playing field. And people do say "oh dear, resharper handles this for me usually". Heck, the built in snippets handle for loops and such, which the whiteboard can't give you. In that case saying something like "I hope the punctuation is right there; I'm a R# guy" is probably all you need to keep me from holding some syntax issues against you.

I need some ability to write understandable code on the whiteboard so we can have a meeting in which we work out how we're going to do things. And of course, I want to see if you have ever actually written code in your life or not. Your interviews may vary.

Title: ReSharper's effect on coding interviews


问:
Can we create desktop application with Ruby?
I know the Ruby on Rails framework is only for web development and not suitable for desktop application development. But if a ruby programmer wants to develop a desktop application, is it suitable and preferable to do it with Ruby only (not jRuby, as most of the tutorials are for jRuby)? If yes, please provide some good tutorials. I want to use linux as OS for development.

Please suggest something, as I am a ruby developer and wants to develop desktop application.

答:
Bowline was (the last version goes back to 2010) a framework for making cross platform desktop applications in Ruby, HTML and JavaScript.

On the other side if it interest you, here's a tutorial on deploying a rails app as a desktop app.


答:
The thing about agile is that documentation efforts really have to be driven by the scrum team.  If the developers don't feel external documentation is sufficient for their needs, the user story gets blocked until they do.  If the business feels developers aren't producing adequate documentation, the product owner insists on making it part of the acceptance criteria.  Because of this, I've actually found our documentation to be more focused and effective since moving to scrum.

We use VersionOne to track our user stories, but I'm sure our methods apply to other systems.  It lets you attach files to user stories.  We have found that to be an extremely useful place to put design documents.

For one example that worked really well for us, we had a need to test a new circuit board design as quickly as possible after the prototype was built.  We made two user stories for everything that needed testing:  one to design the test and one to execute the test.  One acceptance criterion for the design story was that the test procedure was fully documented in the execution story.

When we got to the testing part, it went more smoothly than I've ever seen.  We just opened the user story and followed the step by step procedure.  The documentation was exactly what we needed to complete the story, no more and no less.

We have another story in our backlog just to improve the documentation for a chip we use, in order to make it easier for other teams to pick it up for their own products.

In summary, if you feel your documentation is suffering, the solution is as easy as making a separate user story for it, and/or making it part of the acceptance criteria.

Title: Design documents as part of Agile

Body:
At my workplace, we face a challenge in that "agile" too often has meant "vague requirements, bad acceptance criteria, good luck!"  We're trying to address that, as a general improvement effort.

So, as part of that, I am proposing that we generate design documents that, above and beyond the user story level, accurately reflect the outcome of preliminary investigations of the effect of a given feature within the system and including answers to questions that we have asked the business.

Is there an effective standard for this?

We currently face a situation where a new feature may impact multiple areas in our "big ball of mud" system, and estimates are starting to climb due to this technical debt.  Hopefully more thoughtful design processes can help.


答:
For the previous take, see Revision 1 of this answer. However, the comments and edits to the question further clarify what the question is seeking and allow me to be more clear.

Yes, evidence based software engineering (EBSE) is a thing. There appears to be a few efforts toward EBSE databases, such as this one at Durham University and SEED, which was started by a professor at Cal Poly. All of these efforts, as well as ones discussed in a number of papers that can be found through the IEEE Xplore server or the ACM Digital Library (subscription or purchase required for many papers in both), are based on evidence-based medicine. They provide literature reviews of published empirical (observation and experiment) data. In fact, including "literature review" in a search string on any publication search yields information on most topics - over 14000 hits on the ACM and over 1000 on the IEEE database (when limited to only computing topics).

Looking at the general types of topics discussed in these EBSE databases and literature reviews, I see a common thread - they tend to be technology-independent. The emphasis appears to be mostly centered around process and methodology rather than the specific tools used to conduct software engineering.

So, this concept exists in software engineering. Academia is aware of the evidence-based concept and can successfully apply it to software engineering.

Specifically, the question addresses applying EBSE techniques to the selection of a paradigm seems difficult, due to the sheer number of variables involved, forcing assumptions to be made as well as reducing the ability to repeat the experiment or observation. It's said right in the question - "which paradigm comes out as "the right answer" can depend on what metrics a particular study pays attention to, on what conditions the study holds constant or varies, and doubtless on other factors too". Although that doesn't mean that studying which paradigm is "best" in a given situation, it makes any kind of literature review of these documents incredibly difficult to complete and still extract information across them.

There definitely isn't a "turn the crank" solution to choosing a paradigm.

Given a programming paradigm, you can find studies in the various academic and industry databases about how that paradigm influences various aspects of software development - quality, defects, efficiency, and so on - under various specific conditions, ranging from the knowledge and experience of the team to the problem domain. Any rigorous paper should clearly identify the conditions under which the data was gathered and the assumptions. The problem becomes trying to isolate the factors that make it good in each of those conditions.

Academically, there are some statements that are easy to research. For example, the statement that the functional paradigm is well suited to applications that require concurrency stems from the Church-Rosser theorem. Because of this, it's likely that a software system written in a functional language will have fewer defects related to concurrency than the same system written in a procedural or object-oriented language.

However, from a practical standpoint, a software team can't always use "the best" tool or technique for the job just because research indicates it. Although we strive for producing the highest quality software systems, we do operate within constraints. Often, I see these constraints minimized (or even removed from the equation) when discussing the effectiveness of any methodology.

As a practitioner, when I'm involved in choosing technologies to use, I try to identify the best possible tools. But then I constrain myself to what is known and well-understood by the team that I have. Going back to my previous example, if I have a team well-versed in building concurrent applications in C++ and no experience in Haskell, it doesn't make sense to propose building the system in Haskell as I likely won't be able to make schedule and budget constraints, and my quality will likely suffer due to a lack of experience in the toolchain.

To recap, evidence-based software engineering is generally a good thing that exists and literature reviews do exist and are readily available. However, there are aspects of software engineering where applying evidence-based approaches offer little value. The selection of a programming paradigm to a large scale development effort is one of these.

If you want to find out about how object-orientation addresses reusability or defects in functional programming - you'll easily find publications on those. However, I didn't find (nor would I put any amount of trust in) a publication that was able to effectively address paradigm selection across the broad range of real-world software engineering projects.


答:
If you're using Mac OS X then you'd likely want to use MacRuby, which allows you to create desktop apps. I think its one of the cleanest ways to develop for the desktop using Ruby. Also, I know its not desktop, but you might want to also take a look at RubyMotion, which is compiler and toolchain allowing you to develop iOS apps (iPhone, iPad, iPod touch) using 100% Ruby.

I've personally used the excellent Ruby game library called Gosu which lets you develop for Windows, Linux and Mac (I tried it on Ubuntu Linux). It sits on OpenGL.

Title: Can we create desktop application with Ruby?

Body:
I know the Ruby on Rails framework is only for web development and not suitable for desktop application development. But if a ruby programmer wants to develop a desktop application, is it suitable and preferable to do it with Ruby only (not jRuby, as most of the tutorials are for jRuby)? If yes, please provide some good tutorials. I want to use linux as OS for development.

Please suggest something, as I am a ruby developer and wants to develop desktop application.


问:
Why are cryptic short identifiers still so common in low-level programming?
There used to be very good reasons for keeping instruction / register names short. Those reasons no longer apply, but short cryptic names are still very common in low-level programming.

Why is this? Is it just because old habits are hard to break, or are there better reasons?

For example:

Atmel ATMEGA32U2 (2010?): TIFR1 (instead of TimerCounter1InterruptFlag), ICR1H (instead of InputCapture1High), DDRB (instead of DataDirectionPortB), etc.

.NET CLR instruction set (2002): bge.s (instead of branch-if-greater-or-equal.short), etc.

Aren't the longer, non-cryptic names easier to work with?

When answering and voting, please consider the following. Many of the possible explanations suggested here apply equally to high-level programming, and yet the consensus, by and large, is to use non-cryptic names consisting of a word or two (commonly understood acronyms excluded).

Also, if your main argument is about physical space on a paper diagram, please consider that this absolutely does not apply to assembly language or CIL, plus I would appreciate if you show me a diagram where terse names fit but readable ones make the diagram worse. From personal experience at a fabless semiconductor company, readable names fit just fine, and result in more readable diagrams.

What is the core thing that is different about low-level programming as opposed to high-level languages that makes the terse cryptic names desirable in low-level but not high-level programming?

答:
One reason they use cryptic short identifiers it's because they are not cryptic for the developers. You have to realize they work with it every day and those names are really domain names. So they know by heart what exactly TIFR1 means.

If a new developer comes to the team he'll have to read the datasheets (as explained by @KarlBielefeldt) so they'll get comfortable with those.

I believe your question used a bad example because indeed on those kind of source codes you usually see a lot of unnecessary crypt identifiers for non-domain stuff.

I'd say mostly they do that because of bad habits that existed when the compilers did not auto-complete everything you type.


答:
"vague requirements, bad acceptance criteria, good luck!"

yup, this is the same kind of requirements that you get even if you try to nail them down too! (as an example, a 10,000 requirement document that took a government client 4 years to create was still full of inconsistencies, vagueness and even internally contradictory statements. If 4 years of requirements documentation can't get you a decent, exact, requirement, do you ever think you'll be able to get anything non-vague?)

So... the agile way was invented to understand that this sh*t happens and to work with it rather than try to work against it.

You start of by asking "what do you want" and the customer replies with "something kinda like this". You do some work and then go back to the customer and say "is this like what you wanted?", and the customer usually says "yes but..." whereupon you ask "what do you want".

Eventually you get exactly what the customer wanted, even if they don't know what that is! (hell, they never know what they want, not exactly).

Title: Design documents as part of Agile


问:
Code Review process
I'm looking for a light-weight code review process. A couple of requirements, the reviewer must be able to do the review alone at the time of his/her choosing (not tied to check-ins), the reviewer must be able to easily find the target code, the review has to leave some document showing what was reviewed. I know there are tools available for code review but I work in a very ridig environment and introducing new tools is not an option.

One idea I've been thinking about is to create a new Visual Studio Task List token called REVIEW, and use it to mark the code that needs reviewing.

Something like,

```<code>// REVIEW doe_john: New method, not sure about the exception.
</code>```

Then we would add a Review workitem in TFS (we're using the CMM template).

Another possibility, which I would actually prefer, would be to have developers create a TFS Review workitem and add links to code to it, but I don't know if this is possible. Obviously you can add a link to a file, but I'd like to have a link to a particular method.

答:
Here's some good info: https://stackoverflow.com/questions/68835/code-review

I liked:

Explain context of the change I am reviewing.

Show me your unit tests.

Show me your code.

Show me zero StyleCop warnings and zero FXCop violations.

Show me all this building on the Continuous Integration server.

Very nice and lightweight.

(BTW odd that we share the same name...)

OwnerDisplayName: Rubio

Title: Code Review process

OwnerDisplayName: Andy Rubio


问:
is 'protected' ever reasonable outside of virtual methods and destructors?
so, suppose you have some fields and methods marked protected (non-virtual). presumably, you did this because you didn't mark them public because you don't want some nincompoop to accidentally call them in the wrong order or pass in invalid parameters, or you don't want people to rely on behaviour that you're going to change later.

so, why is it okay for that nincompoop to use those fields and methods from a subclass? as far as i can tell, they can still screw up in the same ways, and the same compatibility issues still exist if you change the implementation.

the cases for protected i can think of are:
non-virtual destructors, so you can't break things by deleting the base class.
virtual methods, so you can override 'private' methods called by the base class.
constructors in c++. in java/c# marking the class as abstract will do basically the same.

any other use cases?

答: The point of protected is not that extension programmers are smarter than application programmers, and therefore are allowed more. They aren't. There's just fewer of them. There are valid arguments for why protected breaks encapsulation and should be avoided if possible; but the world is not perfect, and perfect encapsulation is not a good goal, because in practice it conflicts with too many other valid goals. Therefore it still makes sense to offer class authors a means to expose stuff to some but not all others. Being a good programmer largely consists in being able to make informed decisions about such trade-offs.


答:
I love working in Ruby, and I don't have much opportunity or desire to do web development, so I tried doing exactly this. I grabbed ruby-gnome2 to give me an interface framework and got a good deal of (fairly basic) stuff.

Then I tried it out on a VM under Linux. And sending it to friends. And I learned how horribly difficult it is to distribute Ruby code. For example, the Ruby Windows Installer gives you a lot of basic libraries (such as YAML) for free, which don't come under Linux (and I never did find the right gem install for it). Some libraries work on one OS and not another. A lot of the graphical stuff, especially lower level* stuff, seems to be entirely broken as of 1.9, and isn't getting updated.

So I wouldn't recommend it really.

Ruby is great for scripting purposes, and if you're completely in control of the deployment environment (like a web server) you can do just fine. But distribution is a pain. You might be able to mitigate this though, by using JRuby or IronRuby, which run on the JVM and CLR respectively. They also give you access to graphical toolkits.

*I had a nasty experience trying to get OpenGL to work with Ruby 1.9.3 on Windows. It turned out to be essentially impossible, even after following several rather arcane guides by people who ran into the same problem.


答:
When you declare a class member protected, it does not mean that you do not want it used accidentally: that is what the private is for. You declare members protected when you have data or behavior that is useful to all subclasses, but not to the users of the class.

The simplest way to see this is examining the Template Method pattern: the base class exposes a service that is useful outside of the class, and provides protected methods that subclasses can override to supply partial behaviors to the template method.

Template method pattern uses protected virtual methods in combination with a public non-virtual one. The situation can be reversed, too - public virtual methods in derived classes may use a protected non-virtual method in the base class to supply data or behavior that should be protected from users outside of the base class. In nearly all situations when a protected member is involved there will be an associated virtual member somewhere along the inheritance chain.

Title: is 'protected' ever reasonable outside of virtual methods and destructors?

Body:
so, suppose you have some fields and methods marked protected (non-virtual). presumably, you did this because you didn't mark them public because you don't want some nincompoop to accidentally call them in the wrong order or pass in invalid parameters, or you don't want people to rely on behaviour that you're going to change later.

so, why is it okay for that nincompoop to use those fields and methods from a subclass? as far as i can tell, they can still screw up in the same ways, and the same compatibility issues still exist if you change the implementation.

the cases for protected i can think of are:
non-virtual destructors, so you can't break things by deleting the base class.
virtual methods, so you can override 'private' methods called by the base class.
constructors in c++. in java/c# marking the class as abstract will do basically the same.

any other use cases?


问:
Not specifying a return in a function, good or bad?
I have coded like this many times, and I've never encountered an issue, but the compiler always warns when it expects a return and there is none.

For instance, look at this:

```<code>-(NSString *)outputStringForInteger:(NSInteger)int
{
    if (int == 0)
    {
        return @"Number is Zero";
    }
    else
    {
        return @"Number is not Zero";
    }
    //no "failsafe" or other explicit return
}
</code>```

If the function will never get to the last line, ever, is it important to still have a failsafe option, or do you guys just deal with compiler warnings?

答:
As long as you have covered all the possible code paths, you're fine.

If your compiler is complaining, there's two possibilities:

1) You think you covered everything and didn't.

2) Your compiler is brain dead.

That said, there's most likely a way that you can restructure the code to placate the compiler and still cover the code paths.  (e.g., drop the else in your example)


答: I haven't tried it myself, but a number of my friends have recommended Crucible. I've always used a process where reviewers mark up the code and then meet to discuss what they found. It works well, but the meetings can be hard to schedule and it's easy to get bogged down in minutiae. Crucible seems to support the same sort of process, but without the need for the meeting.</p>

Title: Code Review process

Body:
I'm looking for a light-weight code review process. A couple of requirements, the reviewer must be able to do the review alone at the time of his/her choosing (not tied to check-ins), the reviewer must be able to easily find the target code, the review has to leave some document showing what was reviewed. I know there are tools available for code review but I work in a very ridig environment and introducing new tools is not an option.

One idea I've been thinking about is to create a new Visual Studio Task List token called REVIEW, and use it to mark the code that needs reviewing.

Something like,

```<code>// REVIEW doe_john: New method, not sure about the exception.
</code>```

Then we would add a Review workitem in TFS (we're using the CMM template).

Another possibility, which I would actually prefer, would be to have developers create a TFS Review workitem and add links to code to it, but I don't know if this is possible. Obviously you can add a link to a file, but I'd like to have a link to a particular method.


问:
Is it a common practice to minimize JavaScript usage when building a website?
I've been a web developer for almost 10 years and I've gotten into the habit of trying not to use JavaScript whenever possible. I'm not talking about building web apps here, but database driven websites.

Is this a good/respected approach?

答:
Old-fashioned approach is totally outdated. For example I've made an ajax-deletion for moderator on one of the sites and he is just happy because of the obvious speed increase.

Of course developer can do two versions both for JS and non-JS users, but in most of the cases it's extremelly expensive and doesn't worth 1-2% of the website audience (if you are not Google, of course).

So my answer would be NO — JavaScript is the answer for many user-experience questions, why shouldn't I use it?


问:
How do you name your personal libraries?
I'm pretty bad with naming things.

The only name I can every generically come up with is 'helper'. Say, if I have a header file that contains helping functions for manipulating paths, I tend to put it inside my "helper" directory and call it "path-helper.hpp" or something like that.

Obviouslly, that's a bad naming convention. :)

I want to have a consistent naming scheme for my folder (and namespace) which I can use to always refer to my own headers and libraries, but I have trouble finding names that are easy to type or remember (like boost)... so I end up calling some of them "helper" or "stdext" or whatnot, which isn't a great idea.

How do you find names for your libraries that are easy to remember and easy to type, and which aren't too generic (like "helper" or "std" or "stdext" or the like)?

Any suggestions on how to go about doing this?

答:
I'm also very bad at this. My pragmatic approach is to use enrich the name by date and/or project and/or location till I come up with a reasonable name.

I know for another person it's impossible to read, but myself I can quickly recognize them. And most of these libraries end up single use anyway for me.


答:
Objective-C is modern, compiled alternative to straight C and C++. It has both garbage-collected and deterministic memory management and the message-passing OO runtime has been optimized for performance.

It is available through GCC and CLang and there are application libraries such as GNUStep and Cocotron which work on various platforms.

If you're doing high-performance work, I'm going to assume that's kind of number-crunching or other divide-and-conquer work instead of UI, so that means you could do the UI in whatever language is easiest for you, e.g. HTML via a mini http server.

Title: Compilable modern alternatives to C/C++

Body:
I am considering writing a new software product. Performance will be critical, so I am wary of using an interpreted or language or one that uses a emulation layer (read java).

Which leads me to thinking of using C (or C++) however these are both rather long in the tooth. I haven't used either for a long time. I figured in the last 20 years someone has probably created something which is reasonably popular, nice to code in and compiled.

What more modern alternatives are there to C for writing high performance compiled code?

If C++ is a different beast than it was 15 years ago, I would consider it, I guess I had an assumption that it had some inherent problems.

Parallelisation would be important, but probably not across multiple machines.


问:
What was the first consumer-oriented hardware/software solution?
We all know the story of the personal computer as a consumer-oriented product. But I just thought that real end user solution should have appeared before that time. So a product that was probably expensive, but allowed using it as a service charging for it, for example computer-terminal for transport time-table access or game machine. On the other site, the video terminals as we know them appeared not so long ago. So if there was something like this, this could be hardware/software most likely offering no interactivity, but probably printing some information based on user actions. </p>

答:
The TRS-80 was one of the earliest mass-produced packages.  Not sure that it would count as the fisrt though.  Wikipedia pegs its release as Aug 3, 1977.

(Props to Michael Borgwardt for the comment).  The Commodore PET was released in January of 1977, predating the TRS-80.

The Altair 8800 was the basis for the TRS-80 and went on sale in late 1974 / early 1975.  It's likely the first product to meet your definition.  The Altair had a pretty good commercial run as a consumer-oriented product.  Per Wikipedia:

```The January 1975 issues appeared on newsstands a week before Christmas of 1974
and the kit was officially (if not yet practically) available for sale ```

From what I have found, the references predating the Altair are for programmable calculators.  While there is some blur between the two realms, I believe the Altair meets your definition of first hardware / software package.

Body:
The TRS-80 was one of the earliest mass-produced packages.  Not sure that it would count as the fisrt though.  Wikipedia pegs its release as Aug 3, 1977.

(Props to Michael Borgwardt for the comment).  The Commodore PET was released in January of 1977, predating the TRS-80.

The Altair 8800 was the basis for the TRS-80 and went on sale in late 1974 / early 1975.  It's likely the first product to meet your definition.  The Altair had a pretty good commercial run as a consumer-oriented product.  Per Wikipedia:

The January 1975 issues appeared on newsstands a week before Christmas of 1974
and the kit was officially (if not yet practically) available for sale

From what I have found, the references predating the Altair are for programmable calculators.  While there is some blur between the two realms, I believe the Altair meets your definition of first hardware / software package.


问:
Actions and Controllers managing strategy in MVC apps
Can anyone name any usefull strategy/architectural pattern for allocating actions between different controllers when using MVC pattern for developing web application?

I am now developing web app using asp.net Mvc3 framework and still can't figure out how to manage actions and controllers. One approach is to create single action controller for each url, but it's not the best choice since to much controllers have to be created. Should I list all available urls that are supported by me web app, devide them into groups and create separate controller for each group or act in any different manner?

It seems like I will become face to face with some kind of mess with no consistent approach in managing actions and controllers.

答:
The best thing for you to do is just to start with the default MVC scheme - where controllers and actions are 'allocated' by URL convention, with the first part of the path determining the controller, and the rest of the URL (and the request type, e.g. GET or POST) determining the action that'll be called.

Whilst at first this seems like it must lead to a 'mess' the reality is that most websites don't actually require loads of controllers, and certainly don't require loads of actions.

Sometimes you might wish to do some clever stuff to split one controller into two, whilst keeping the URLs the same - e.g you might have:

~/Products going to ProductsController.GetProducts()

~/Products/{id} going to ProductsController.GetProduct(id)

But then, let's say you have reviews of products too, you might have

~/Products/{id}/Reviews going to ProductReviewsController.GetReviews(id)

This could be legitimate since reviews functionality might require quite a lot of code, which isn't directly related to the products themselves.

That said, the motivation for splitting controllers shouldn't be to keep a code-file small (you can do that with partial classes), it should be to keep to a single-responsibility principle; that is - a controller should have responsiblity for single section of your site.  The Users controller should not also be used for your homepage.

Don't spawn a new controller for everything you do, consider it based on the entity that the controller will operate on or provide details of (e.g. products, users etc).  Thinking URL-first and then using that as the basis for new controllers is a very good starting point, because ultimately you want your site to be easily navigable by search engines as well as users.

The beauty of MVC, also, is that with the separation of controllers from the route patterns that trigger their actions, you can completely change the URL structure of all your existing code just by changing the routing.  For that reason it's particularly important to remember always to use the UrlHelper for generating URLs to other actions, and HtmlHelper's ActionLink and RouteLink operations in views for generaing cross-links; these honour routing, and so take away a lot of the pain associated with re-structuring a website at the URL level.

OwnerDisplayName: singleton

OwnerDisplayName: Andras Zoltan


答: It would, as you suggest, probably be an arcade game console. A quick Wikipedia search turns up Computer Space, generally agreed upon as the first coin-operated electronic video game ever marketed (though Pong had greater success). However, there's an even earlier one: Spacewar!, not coin-operated, but one of the first popular examples of what a computer could do for the masses. That was developed in 1961-2. However, the PDP-1 on which it was programmed was by no means a "consumer-oriented" platform; these were marketed to big companies and universities. It wasn't until the 70s with Computer Space and Pong that a computer powerful enough to play a game like that could fit in a console, and it really wasn't until the Atari 2600 beginning in '77 that the masses could buy a computer and then buy software to plug into the computer.</p>

Title: What was the first consumer-oriented hardware/software solution?

Body: We all know the story of the personal computer as a consumer-oriented product. But I just thought that real end user solution should have appeared before that time. So a product that was probably expensive, but allowed using it as a service charging for it, for example computer-terminal for transport time-table access or game machine. On the other site, the video terminals as we know them appeared not so long ago. So if there was something like this, this could be hardware/software most likely offering no interactivity, but probably printing some information based on user actions. </p>


答: The very earliest thing that might fit your description (while stretching it) would be teletypewriters which became available in the 1920s, first as clients for telegraph systems, but which were also the first remote computer terminals before screen-based terminals became available in the 1970s. This heritage is still visible in the abbreviation TTY for virtual consoles in Unix systems.</p>


问:
How to Properly Make use of Codeigniter's HMVC
I have been having problems wrapping my brain around how to properly utilize the modular extension for Codeigniter. From what I understand, modules should be entirely independent of one another so I can work on one module and not have to worry about what module my teammate is working on. I am building a frontend and a backend to my site, and am having confusion about how I should structure my applications.

The first part of my question is should I use the app root controllers to run modules, or should users go directly to the modules by urls?
IE: in my welcome.php

```<code>public function index()
{
  $this->data['blog'] = Modules::run( 'blog' );
  $this->data['main'] = Modules::run( 'random_image' );
  $this->load->view('v_template', $this->data);
}

public function calendar()
{
  $this->data['blog'] = Modules::run( 'blog' );
  $this->data['main'] = Modules::run( 'calendar' );
  $this->load->view('v_template', $this->data);
}
</code>```

My second part of the question is should I create separate front/back end module folders

```<code>-config
-controllers
  welcome.php
  -admin
    admin.php
-core
-helpers
-hooks
-language
-libraries
-models
-modules-back
  -dashboard
  -logged_in
  -login
  -register
  -upload_images
  -delete_images
-modules-front
  -blog
  -calendar
  -random_image
  -search
-views
  v_template.php
  -admin
    av_template.php
</code>```

Any help would be greatly appreciated.

答:
Just sharing what I do.

I let the users directly access the module.
I have separate controllers for both backend and frontend for the module within the module.

All the backend controllers extend Admin_Controller and frontend controller extend Front_Controller.

The admin page is rendered by the module itself (there is a master template for the admin area/front area and the module fills the main working area in the template).

All the requests are handled by the modules itself.

This way both backend and frontend are solely handled by the module itself.

My folder structure is slightly different than yours:

```<code>+application
|--+modules
   |--+content
      |--+controllers
      |  |--+admin
      |     |--Content_Controller.php (This handles the backend requests)
      |  |--Content_Controller.php (This handles the frontend requests)
      |--models
      |--+views
      |  |--+admin (this contains the views for backend)
      |  |--+front (this contains views for front end)
</code>```

So if you need to remove the content module just remove the folder from the modules directory. :)

Body:
Just sharing what I do.

I let the users directly access the module.
I have separate controllers for both backend and frontend for the module within the module.

All the backend controllers extend Admin_Controller and frontend controller extend Front_Controller.

The admin page is rendered by the module itself (there is a master template for the admin area/front area and the module fills the main working area in the template).

All the requests are handled by the modules itself.

This way both backend and frontend are solely handled by the module itself.

My folder structure is slightly different than yours:

+application
|--+modules
   |--+content
      |--+controllers
      |  |--+admin
      |     |--Content_Controller.php (This handles the backend requests)
      |  |--Content_Controller.php (This handles the frontend requests)
      |--models
      |--+views
      |  |--+admin (this contains the views for backend)
      |  |--+front (this contains views for front end)

So if you need to remove the content module just remove the folder from the modules directory. :)


问:
Five new junior developers and lots of complex tasks. What's now?
Our company has hired five new junior developers to help me to developer our product. Unfortunately the new features and incoming bug fixes usually require deeper knowledge than a recently graduated developer usually has (threading/concurrency, debugging performance bottlenecks in a complex system, etc.)

Delegating (and planning) tasks which they (probably) can solve, answering their questions, mentoring/managing them, reviewing their code use up all of my time and I often feel that I could solve the issues less time than the whole delegating process takes (counting only my time). In addition I don't have time to solve the tasks which require deeper system knowledge/more advanced skills and it does not seem that it will change in the near future.

So, what's now? What should I do to use their and my time effectively?

答:
Yes you can solve things faster than they can, that's why you are senior and they are not. However, a good senior wants to take his juniors to the senior level as well and the only way you can do this is by letting them learn how to do things.

Mentoring is the most effective use of your time right now, not coding.

Look at it this way, if you spend the next six months mentoring effectively and the juniors learn enough to become intermediate developers - then you have 5 intermnediate develoeprs and one senior. If you do all the hard work yourself because it is faster, in six months you wil stil lhave 5 juniors twiddling their thumbs (well the best of them will have moved on to other jobs by then if you give them no challenging work, so you may have fewer or newer junior devlopers) and one overworked and cranky senior.

You know what complex interactions are typically found in the bugs, so develop some training specifically on those types if things, how to troublshoot and find the actual problem and then the types of methods typically needed to fix them. Then give them those problems as they come up. Yes they will take longer to fix them and you should allow for that in your time estimates.

The pair programming idea is great. Pair with a different one for each problem that is truly advanced. Even if they don't know enough to solve the problem yet, having the junior at the keyboard while you tell them what to try in terms of looking for the cause will help teach them the process of troubleshooting. Of course, don't just expect them to take dictaion. explain what you want them to look for and why. Ask for their ideas and listen to them. Explain why their idea is not a good choice if it is not. Use the Socratic method of teaching by asking leading questions. They will remember better the solution they came up with themselves through your leading questions than the one you dictated to them without explanation. They will aslo remember better if they actaully typed the solution rather than just watched you type it. One of the main priciples of learning is that people retain more if they do rather than just listen.

Once the junior has helped you solve a particular class of problems as part of a pair with you, you can pair him up with someone else the next time that class of problem comes up and only be available for consulting, not standing over their shoulders while they try different things.

You have five new people which is really hard. You need to be fair to all of them and rotate who you pair with or give the guidance to. Don't play favorites.  BUt you wil also need to be a person who provides "Tough love" if someone is not succeeding and making progress.  YOu may need to call one or more of them aside and tell them that they need to improve and why you feel they are not succeeding. SOme peopel will let you do all teh work if you pair and you can;t allow this just becasue it is easier. If teh person can't do the work, it is kinder to them and much better for your team if you don't carry them once it is obvious that they cannot or will not learn to be more independent.

Remember, you get what you expect. If you don't expect much, you won't get much. Expect them to shine and most of them will come up to your standard.


答:
Think like you are developing an API. Now you need to think how to make it much better so that users can use or can use with some customization.

In a API you need to use :

public methods : so that developers can use the provided features.

private methods : developers don't confused or your api breaks.

protected methods : so that if some are more intelligent and want to extend your code they can.

Sometimes while creating a software design/architecture we need to hide some internals from caller Classes but those are necessary by sub-classes. Example (Java):
What if java.lang.Object changes protected void finalize() access to public or private. Definitely this would create problems.


问:
Inheritance, commands and event sourcing
In order not to redo things several times I wanted to factorize common stuff. For Instance, let's say we have a cow and a horse.  The cow produces milk, the horse runs fast, but both eat grass.

```<code>public class Herbivorous
{
   protected int Quantity;

   public void EatGrass(int quantity)
   {
      var evt= Build.GrassEaten
                    .WithQuantity(quantity);
      RaiseEvent(evt);
   }

   public void Apply(GrassEaten evt)
   {
       _quantity= evt.Quantity;
   }
}

public class Horse : Herbivorous
{
   private bool _HasFastRun;

   public void RunFast()
   {
      var evt= Build.FastRun;
      RaiseEvent(evt);
   }

   public void Apply(FastRunevt)
   {
       _HasFastRun= true;
   }
}

public class Cow: Herbivorous
{
   private bool _IsMilkProduced;

   public void ProduceMilk()
   {
      var evt= Build.MilkProduced;
      RaiseEvent(evt);
   }

   public void Apply(MilkProduced evt)
   {
       _IsMilkProduced= true;
   }
}
</code>```

To eat Grass, my application receives a command in Json or xml, or whatever that deserialise into this class:

```<code>namespace Herbivorous
{
   public class EatGrass : CommandBase
   {
      public Guid IdHerbivorous {get; set;}
      public Guid CommitId {get; set;}
      public long Version {get; set;}
      public int Quantity {get; set;}
   }
}
</code>```

The command handler should be :

```<code>public class EatGrassHandler : CommandHandler<EatGrass>
{
   public override CommandValidation Execute(EatGrass cmd)
   {
      Contract.Requires<ArgumentNullException>(cmd != null);
      Herbivorous herbivorous= EventRepository.GetById<Herbivorous>(cmd.Id);
      if (herbivorous.IsNull())
         throw new AggregateRootInstanceNotFoundException();
      herbivorous.EatGrass(cmd.Quantity);
      EventRepository.Save(herbivorous, cmd.CommitId);
   }
}
</code>```

so far so good. I get a Herbivorous object , I have access to its EatGrass function, whether it is a horse or a cow doesn't matter really. The only problem is here :

```<code>EventRepository.GetById<Herbivorous>(cmd.Id)
</code>```

Indeed, let's imagine we have a cow that has produced milk during the morning and now wants to eat grass.  The EventRepository contains an event MilkProduced, and then come the command EatGrass.
With the CommandHandler, we are no longer in the presence of a cow and the herbivorious doesn't know anything about producing milk . what should it do?

Should I have explicit contextual command  like :

```<code>namespace Herbivorous.Cow
    {
       public class EatGrass : CommandBase
       {
          public Guid IdHerbivorous {get; set;}
          public Guid CommitId {get; set;}
          public long Version {get; set;}
          public int Quantity {get; set;}
       }
       public class ProduceMilk : CommandBase
       {
          public Guid IdHerbivorous {get; set;}
          public Guid CommitId {get; set;}
          public long Version {get; set;}
       }
    }
</code>```

This would mean that the external component that asks my herbivorous to eat grass should know that in this bounded context we talk about a cow. in the former command, we were talking about a general Herbivorous behavior, so the context of my call was not important. We knew that we needed herbivorous to eat grass that was all.

This is my main problem possible leakage of domain specific from one bounded context to another.
Actually It might mean too that I cannot support abstraction when working on interfaces between several applications. I wonder...

Or I could just accept any event when rebuilding my herbivorous. It means that if it does not find a method to apply this event to, he will goes just fine trying to apply the next one of its stream. This is the real simple solution, but it does not put me at ease to know  that events might not be applied ( and not producing errors) when rehydrating my object. (Actually the more I think about it the less I feel guilty..)

Thanks for your help, I am just beginning with these kinds of problem, and I would be glad to have some news from someone more experienced.

答:
First, add a virtual method Execute(cmd) to your Herbivorous, and put the code for the dispatching the commands to the command methods there. Then each subclass of Herbivorous can override that method and support all command methods specific to the subclass. Should look somehow like this:

```<code>public class Cow: Herbivorous
{
   public override void Execute(Command cmd)
   {
      if(cmd is ProduceMilkCommand)
          ProduceMilk(cmd);  // execute specific command
      else
          base.Execute(cmd); // delegate general commands to the base class
   }
}
</code>```

For creating a new object from a given command, add a System.Type field to your cmd and use reflection to create an instance of that specific subtype of Herbivorous. Or use the prototype pattern to create a new instance (your command has to store a reference to that prototype object then instead). A third alternative is to use the abstract factory pattern, your command then will have to store a reference to the right factory subtype.

Of course, I guess I could give you a better answer if you had shown us how the command class currently looks like and how the commands are created. And your use of the "var" command in the code snippets hides some details which may be important for a more precise answer.

Body:
First, add a virtual method Execute(cmd) to your Herbivorous, and put the code for the dispatching the commands to the command methods there. Then each subclass of Herbivorous can override that method and support all command methods specific to the subclass. Should look somehow like this:

public class Cow: Herbivorous
{
   public override void Execute(Command cmd)
   {
      if(cmd is ProduceMilkCommand)
          ProduceMilk(cmd);  // execute specific command
      else
          base.Execute(cmd); // delegate general commands to the base class
   }
}

For creating a new object from a given command, add a System.Type field to your cmd and use reflection to create an instance of that specific subtype of Herbivorous. Or use the prototype pattern to create a new instance (your command has to store a reference to that prototype object then instead). A third alternative is to use the abstract factory pattern, your command then will have to store a reference to the right factory subtype.

Of course, I guess I could give you a better answer if you had shown us how the command class currently looks like and how the commands are created. And your use of the "var" command in the code snippets hides some details which may be important for a more precise answer.


答:
The other answers seem to be focusing on "should I not ever use JavaScript", so I think they're missing the point. You shouldn't use JavaScript if you don't need it. Some people use JavaScript for everything:

Hover effects (should be CSS)

AJAX (should have href when reasonable)

Positioning (should be CSS)

The benefits are things like:

The site displays faster

CSS is significantly less complex than JavaScript most of the time

Having backup href links helps search engines, users who want to open links in other tabs, and users who hate JavaScript

Of course, AJAX is pretty cool, and so are dynamic pages, so don't throw those things away just because some people don't need them.

My point is, learning how to do things without JavaScript is good, minimizing JavaScript is good, and having a backup for when JavaScript doesn't work is good, but there's no reason to avoid features because they require JavaScript.

Title: Is it a common practice to minimize JavaScript usage when building a website?

Body:
I've been a web developer for almost 10 years and I've gotten into the habit of trying not to use JavaScript whenever possible. I'm not talking about building web apps here, but database driven websites.

Is this a good/respected approach?


问:
How much should I rely on Visual Studio's Auto Generated Code?
I'm reading about ASP.NET (VB.NET) and I want to built my professionally website. I'm wondering though; I'm still using the basics so I'm really just a novice, but how much should I rely on Visual Studio to create my elements?

Should I make my own text boxes and have my own login routine, or should I just use ASP.NET's login features?

I know eventually you have to use your own classes and such which is where the real coding comes in, but I'm not sure how relaible, flexible and secure the pre-wrote elements are?

Any help would be greatly appreciated.

答:
The "real coding" comes in where you're adding unique value to whatever it is you're developing.

If you're spending time re-inventing the wheel and choosing to write what will - almost inevitably - be less comprehensive implementations to solve common problems then you're not really adding value.

Fundamentally therefore you trust the generated code (or packaged/library code) until you have good reason not to.

However, I suspect you don't mean "code" you actually mean "markup" (i.e. HTML and, by extension, CSS - and javascript, though that's code again!) and that's a somewhat different question - and a somewhat broader one since there are a number of possibilites in terms of how that markup is specified and generated. Old web forms code does things that are "not nice" although, as it turns out, are more than adequate to a lot of purposes whereas with MVC you have very fine grained control of what appears in the client browser. (And with the latest version of web forms MS has attempted to ensure that their markup is a lot cleaner.)

Ultimately if you're putting up a "public" facing website (which is the implication) you want to have a high level of control over the markup. There are any number of ways you can do this with the MS stack - ASP.NET MVC is the "in house" tool - there are others.


问:
How does the GPL work in regards to languages like Dart which compile to other languages?
Google's Dart language is not supported by any Web Browsers other than a special build of Chromium known as Dartium. To use Dart for production code you need to run it through a Dart->JavaScript compiler/translator and then use the outputted JavaScript in your web application.

Because JavaScript is an interpreted language everyone who receives the "binary"(Aka, the .js file) has also received the source code.

Now, the GNU General Public License v3.0 states that:

"The “source code” for a work means the preferred form of the work for making modifications to it."

Which would imply that the original Dart code in addition to the JavaScript code must also be provided to the end user. Does this mean that any web applications written in Dart must also provide the original Dart code to all visitors of their website even though a copy of the source code has already been provided in a human readable/writable/modifiable form?

答:
The basic question is:

Does including javascript on web page (e.g. referencing via a script tag) count as "Conveying" the GPLed work?

If it does, you must make the source available in the preferred form for modifying the code, if not you don't. In this case the preferred form is the original Dart source code used to generate the javascript.

I can't find an explicit answer to this question on the FSF site but Stallman's essay "The Javascript Trap" seems to indicate that he does consider it Conveying and as such you would have to make the original Dart source code available. See his note about allowing minified versions that do not include the text of the license but are still covered by the license.

See also this FAQ about javascript and templates for an exception that would allow templates to use GPLed javascript without being GPLed.

The absolute best way to know if what you want to do is compliant with the license is to ask the Copyright holder of the code, because only they have the right to enforce the license. They may have interpreted the license differently and be willing to add an exception to make their interpretation explicit.


问:
Empirical evidence for choice of programming paradigm to address a problem
The C2 wiki has a discussion of Empirical Evidence for Object-Oriented Programming that basically concludes there is none beyond appeal to authority. This was last edited in 2008. Discussion here seems to bear this out: questions on whether OO is outdated, when functional programming is a bad choice and the advantages and disadvantages of AOP are all answered with contributors' opinions without reliance on evidence.

Of course, opinions of established and reputed practitioners are welcome and valuable things to have, but they're more plausible when they're consistent with experimental data. Does this evidence exist? I know that evidence-based software engineering is a thing, but can I practice it in this context? Specifically, if I have a particular problem P that I want to solve by writing software, does there exist a body of knowledge, studies and research that would let me see how the outcome of solving problems like P has depended on the choice of programming paradigm?

I know that which paradigm comes out as "the right answer" can depend on what metrics a particular study pays attention to, on what conditions the study holds constant or varies, and doubtless on other factors too. That doesn't affect my desire to find this information and critically appraise it.

It becomes clear that some people think I'm looking for a "turn the crank" solution - some sausage machine into which I put information about my problem and out of which comes a word like "functional" or "structured". This is not my intention. What I'm looking for is research into how - with a lot of caveats and assumptions that I'm not going into here but good literature on the matter would - certain properties of software vary depending on the problem and the choice of paradigm.

In other words: some people say "OO gives better flexibility" or "functional programs have fewer bugs" - (part of) what I'm asking for is the evidence of this. The rest is asking for evidence against this, or the assumptions under which these statements are true, or evidence showing that these considerations aren't important. There are plenty of opinions on why one paradigm is better than another; is there anything objective behind any of these?

答:
I've been reading The Art of Unix Programming by Eric S. Raymond.  It has some very interesting historical insights about things we now take for granted.  He cites some good studies from IEEE software that use empirical evidence like defect density.  That might be a good source if you're looking for academic-style studies.

Even techniques like modularizing using functions were not always common practice.  One of my favorite quotes from the book so far:

Dennis Ritchie encouraged modularity by telling all and sundry that
  function calls were really, really cheap in C. Everybody started
  writing small functions and modularizing. Years later we found out
  that function calls were still expensive on the PDP-11, and VAX code
  was often spending 50% of its time in the CALLS instruction. Dennis
  had lied to us! But it was too late; we were all hooked...

-- Steve Johnson

There are really two problems with getting too empirical, though.  The first is that code quality is a very subjective thing.  Code can be terrible and still be correct.  People's perception of a programming paradigm is a very valid metric, because code is written for people to read as much as for computers, if not more.

The second problem is that 50% of developers have below average programming talent.  It doesn't matter if your top developer is more productive using functional programming if the "rabble" struggles to write working software using it, let alone beautiful, well-architected software.  Likewise with TMTOWTDI programming languages, your top developer is still going to write clean, modular code, but less talented coders write line noise due to the lack of imposed structure.

That's why I think OOP has risen to the top in popularity despite its deficiencies.  It's not so restrictive that it hobbles the most talented, but its structure provides a concise way to communicate and impose good design principles on the least talented.

In our line of work we have a tendency to evaluate a solution based too much on its technical merits alone.  A successful endeavor has to account for the human side of the equation as well.


问:
What are use cases and advantages of pointers?
I often struggle to see the advantages of pointers (except for low level programming).

Why use of char* instead of a String or char[] or what advantages pointer arithmetic brings.

So what are the pros and use cases of pointers?

答: Pointers provide a visibility into the machine that is required for most interesting programming. Most modern languages simply hide the gritty bits from you.</p>


问:
microsoft .Net license
Am about to start coding using microsoft .Net technologies, am just worried about the license, so if I compile my code using the .Net compiler "not visual studio" can I distribute, sell or use my product freely or I should have some sort of "microsoft license", same thing for sql server express installed(depolye) with my application

答:
You don't need Visual Studio to create distributable applications.  It's perfectly legal to get the SDK, use Notepad to create your application, compile it with the command line compiler (csc.exe for C#), and sell or distribute the resulting program to anyone.

You pay for Visual Studio to get the additional features that Visual Studio provides.

Title: microsoft .Net license


问:
Performing user authentication in a CodeIgniter controller constructor?
In "The Clean Code Talks -- Unit Testing", Miško Hevery mentions that "as little work as possible should be done in constructors [to make classes more easily testable]'. It got me thinking about the way I have implemented my user authentication mechanism.

Having delved into MVC development through CodeIgniter, I designed my first web application to perform user authentication for protected resources in controllers' constructors in cases where every public function in that controller requires the user to be authenticated.

For controllers with public methods having mixed authentication requirements, I would naturally move the authentication from the constructor to each method requiring authentication (though I don't currently have a need for this).

I made this choice primarily

to keep the controller tight, and

to ensure that all resources in the controller are always covered.

As for code longevity and maintainability: given the application structure, I can't foresee a situation in which one of the affected controllers would need a public method that didn't require user authentication, but I can see this as a potential drawback in general with this implementation (i.e., requiring future refactoring).

Is this a good idea?

答:
This is what I do too.

The simplicity of the code for checking authenticaton in the construct is more favorable to me  (the construct is not too fat either).

I check the minimal permission required in the construct and individual permissions in the individual methods.

If all the method of the controller require same and only minimal permissions, i just put them in the construct.

One other form of the implementation is separating the controller for Authenticated users.

The backend controllers would extend 'Admin_Controller' which checks authentication in its construct, thereby restricting any operations it the user is not authenticated.

This makes the code more reusable and reliable.


问:
Why don't interviewers  ask the applicant to read some code?
I had a dozen interviews in my life (I'm about to graduate) and I wonder why I was only once asked to read and explain some code. Roughly, 90% jobs are mostly about maintaining existing systems. IMO ability to read someone else's code is an important skill.

Why don't interviewers check it?*

*Among my friends I am the only one that was asked to review some code.

答: When I was asking interview questions I did at first but slowly phased it out. The applicants that could write code well in the interview could all read code well in the interview. The applicants who couldn't read code couldn't write it either. The questions involved in reading code didn't really differentiate any applicants.</p>


答:
Reading is an assumption based on the fact that ability is present for writing. Consider the concept in any language. Programming is just a language to communicate between human and machine. Consider a human to human communication. If you were hiring someone to be an interpreter for Japanese, wouldn't it stand to reason that if they could write a 1,000 word essay on a particular topic that they would be able to read it?

As programmers, our primary activity is the creation of code and the translation of abstract ideas into concrete implementations. This generally means writing. I agree that reading is just as critical, but in a large majority of cases, where writing ability is present reading ability is also present. The only real case where I could see a distinguishable difference would be in an environment where there are a lot of highly complex cases that have evolved over time. Even given these, though, you would not expect someone to be able to read them and understand them without at least some study.

Also, reading code and explaining what you think it does doesn't really express to an interviewer how you use your critical thinking skills. It shows a bit of analysis, but most employers want to see if you can think without being placed into a box. They want to know if you can grasp the concepts without the benefit (or crutch even) of existing code to tell you what or how to do something.

Title: Why don't interviewers  ask the applicant to read some code?

Body:
I had a dozen interviews in my life (I'm about to graduate) and I wonder why I was only once asked to read and explain some code. Roughly, 90% jobs are mostly about maintaining existing systems. IMO ability to read someone else's code is an important skill.

Why don't interviewers check it?*

*Among my friends I am the only one that was asked to review some code.


答:
You can even distribute commercial applications with their FREE Visual Studio Express products. There are no  commercial restrictions in regards to the .NET framework. The only thing you cannot do is publish performance metrics of the .NET framework itself without Microsoft's permission.

Microsoft wants you to use their products to produce commercial software. They don't want their to be anything in the way of that. IF you like Visual Studio download the Express version.

Title: microsoft .Net license

Body: Am about to start coding using microsoft .Net technologies, am just worried about the license, so if I compile my code using the .Net compiler "not visual studio" can I distribute, sell or use my product freely or I should have some sort of "microsoft license", same thing for sql server express installed(depolye) with my application


问:
Asking for a code sample of the company at an interview
Asking a job seeker to show some code is a fairly common practice for a software company. However, would it be acceptable for the candidate to ask the interviewer to show him a small piece of code that he thinks is well written?</p>

答:
However, would it be acceptable for the candidate to ask the interviewer to show him a small piece of code that he thinks is well written?

I suppose that falls into the whole 'interviews are bidirectional' mantra, but I wouldn't expect to get any. Intellectual Property concerns are the most obvious issue after the fact that there's no computer in the interview room, and bringing you to one is kinda awkward.

Further, they're just going to cherry pick the best looking, least meaningful code they can. The best code isn't really a problem, the worst is. It's the same reason that getting code samples from candidates is next to useless.


答:
Short version

If the job consists of maintaining an application, the skills you need to test during interviews are:

The ability to understand the large codebase with its documentation, unit tests, etc.

The ability to refactor the code and to bring changes without breaking everything.

Asking people to read code will not help you to evaluate those abilities.

Long version

Were you asked writing code? If yes, as Sign noted in his answer, this is enough. If we generalize a bit, a person who write clear, easy to understand source code would be able to read source code written by other people.

If you weren't asked to write code, then, well, you were probably interviewed by a person from human resources department. Such interviews cannot be too technical, and are mostly worthless, since they don't asset your skills and your ability to work well, but rather the number of years you spent in college and other things which has nothing to do with the job.

There are a few more reasons to not asking to read code for a maintenance job:

1. It's difficult to do reliably

Concretely, what would you do if you were an interviewer? Make your candidates read some code. What code? In what language? How well or badly written? With or without comments? With or without documentation?

More importantly, what does it tell about the candidate? How well does it correlate with codebase itself?

Let's say you have a legacy VB.NET app to maintain. You know that the source code is mostly ugly and untested, and a few comments are outdated or misleading. For the past three months, you had a very skillful developer working on the solution; he refactored and unit tested the most critical parts of the application, added comments where there was a need for comments, and, most importantly, wrote detailed documentation about the overall architecture, the critical parts and the pitfalls.

You're now hiring a developer to maintain this codebase. During an interview, would you give a piece of legacy (ugly untested) code, or the piece of code which was refactored by the previous developer?

Would you give the documentation? In order to read documentation, the candidate will need to spend at least a few hours. This makes it impossible to do during an interview.

2. Reading short piece of code is not the same as reading code of a familiar project

Remember, the job is to maintain a project. It is difficult to maintain a large codebase the first days or weeks when you're not familiar with the project. It's much easier to do it after a few months when you've written all the documentation and have a clear view of the overall codebase.

The most important thing to test is if the person will be efficient those months. You don't care if the person will not be able to understand anything at all the first two days.

By asking a person to read a short piece of code from scratch, you are not testing how this person would be able to deal with a familiar, documented codeabse of thousands of LOC.

3. Maintaining source code is not just reading it

When you are maintaining a codebase, you are modifying it. A developer who just reads code doesn't bring anything useful to his company.

The useful skills are the ability to refactor code, to add unit tests, to predict the impact of a change, etc. You don't test those skills by asking a person to read code during the interview.


问:
FTP file compare
Are there any FTP programs out there that do a file comparison as well, so I can select the local and remote files and see what actually changed? I didnt find any when I googled. But it doesnt seem like a very advanced use case to me. Surely many others would have felt the need for it.. right?</p>

答: Kind of tricky to do a local or remote compare without downloading the file for analysis. So why not just download it or mount the FTP as a folder?</p>

Title: FTP file compare


答:
Well, it depends. I always liked to know where I am going to work.

I see a job interview as bidirectional. The company finds out about you and you find out about the company. Asking for code may be a little bit much, but asking development related questions should be OK.

For example, I would not accept a job where the company doesn't use agile techniques or TDD or doesn't plan to embrace and encourage such practices. I also appreciate when a company is proud of their product and their code -- when it seems the interviewer is waiting for you to ask to see it so he has an excuse to explain all the cool stuff they do.

Title: Asking for a code sample of the company at an interview

Body: Asking a job seeker to show some code is a fairly common practice for a software company. However, would it be acceptable for the candidate to ask the interviewer to show him a small piece of code that he thinks is well written?</p>


问:
What is the difference between `update` and `upgrade`
What is the difference between update and upgrade in the context of application software?

答:
Consider thinking about it this way:

An update is taking something you have and tweaking it a bit, usually to fix something that someone found broken.  Quite often the vendor feels obligated to give this for free, since it's what you should have gotten, how it was advertised, or secures something better.  Occasionally little improvements and optimizations are delivered as well.

An upgrade is getting the next best thing, which usually is new behavior, features, or compatability.  The new software will have noticable functional improvements or additions.


问:
GPL - what is distribution?
An interesting point came up on another thread about alleged misappropriation of a GPL project.  In this case the enterprise software was used by some large companies who essentially took the code, changed the name, removed the GPL notices and used the result.

The point was - if the company did this and only used the software internally then there isn't any distribution and that's perfectly legal under GPL.  Modifications by their own employees for internal use would also be allowed.

So At what point does it become a distribution?

Presumably if they brought in outside contractors under 'work for hire' their modifications would also be internal and so not a distribution.

If they hired an external software outfit to do modifications and those changes were only used internally by the company - would those changes be distributed? Does the GPL apply to the client or to the external developers?

If the company then give the result to another department, another business unit, another company?  What if the other company is a wholly owned subsidiary?

ps.  yes I know the answer is ask a lawyer. But all the discussion I have seen over GPL2/GPL3 distribution has been about webservices - not about internal use.

答:
Look at it this way. It won't really matter if there are different departments, or subsidiaries. It only matters if you are going to distribute the binaries to another party and not give them the source.

If there is another department that will use the modifications, they will get the source to work on it. No big deal. You are complying with everything in the license. Anyone who can get a distribution needs the source.

Services over the network is not considered distribution.

Here is an attempt at a simple explanation of GPL:

If a GPL project produces awesomeProduct.jar, any place that awesomeProduct.jar exists, awesomeProduct_src.jar also needs to exist. If someone doesn't have awesomeProduct.jar they don't get awesemeProduct_src.jar

Title: GPL - what is distribution?


问:
Python Coding standards vs. productivity
I work for a large humanitarian organisation, on a project building software that could help save lives in emergencies by speeding up the distribution of food. Many NGOs desperately need our software and we are weeks behind schedule.

One thing that worries me in this project is what I think is an excessive focus on coding standards. We write in python/django and use a version of PEP0008, with various modifications e.g. line lengths can go up to 160 chars and all lines should go that long if possible, no blank lines between imports, line wrapping rules that apply only to certain kinds of classes, lots of templates that we must use, even if they aren't the best way to solve a problem etc. etc.

One core dev spent a week rewriting a major part of the system to meet the then new coding standards, throwing away several suites of tests in the process, as the rewrite meant they were 'invalid'. We spent two weeks rewriting all the functionality that was lost, and fixing bugs. He is the lead dev and his word carries weight, so he has convinced the project manager that these standards are necessary. The junior devs do as they are told. I sense that the project manager has a strong feeling of cognitive dissonance about all this but nevertheless agrees with it vehemently as he feels unsure what else to do.

Today I got in serious trouble because I had forgotten to put some spaces after commas in a keyword argument. I was literally shouted at by two other devs and the project manager during a Skype call. Personally I think coding standards are important but also think that we are wasting a lot of time obsessing with them, and when I verbalized this it provoked rage. I'm seen as a troublemaker in the team, a team that is looking for scapegoats for its failings. Since the introduction of the coding standards, the team's productivity has measurably plummeted, however this only reinforces the obsession, i.e. the lead dev simply blames our non-adherence to standards for the lack of progress. He believes that we can't read each other's code if we don't adhere to the conventions.

This is starting to turn sticky. Now I am trying to modify various scripts, autopep8, pep8ify and PythonTidy to try to match the conventions. We also run pep8 against source code but there are so many implicit amendments to our standard that it's hard to track them all. The lead dev simple picks faults that the pep8 script doesn't pick up and shouts at us in the next stand-up meeting. Every week there are new additions to the coding standards that force us to rewrite existing, working, tested code. Thank heavens we still have tests, (I reverted some commits and fixed a bunch of the ones he removed).

All the while there is increasing pressure to meet the deadline.

I believe a fundamental issue is that the lead dev and another core dev refuse to trust other developers to do their job. But how to deal with that? We can't do our job because we are too busy rewriting everything.

I've never encountered this dynamic in a software engineering team. Am I wrong to question their adherence to coding standards? Has anyone else experienced a similar situation and how have they dealt with it successfully?
(I'm not looking for a discussion just actual solutions people have found)

答:
Someone needs to decide if shipping or slavish adherence to coding standards is the real priority.  I know what my preference would be; if it's passing unit and acceptance tests, I say ship.  Once it ships, the company can decide whether or not to spend the time and money to fix the technical debt.

Problems with spaces after commas are easily solved with a code prettifying tool.  Find a tool that enforces all of your coding conventions, and run that tool on all modified code before the build and testing takes place.  Decent IDE's already do this, while you're writing the code.


答:
Not free, but really worth its price: Beyond Compare
You can test it 30 days for free (really 30 test days, not 30 days after installation).

You can compare folders (with subfolders) and files.  FTP sites and zip files are integrated.

See also a screenshot on the website of the producer and the documentation for FTP profiles.

Title: FTP file compare

Body: Are there any FTP programs out there that do a file comparison as well, so I can select the local and remote files and see what actually changed? I didnt find any when I googled. But it doesnt seem like a very advanced use case to me. Surely many others would have felt the need for it.. right?</p>