问:
What's a technical way to describe removed functionality in a software application or framework?
I'm not trained programmer, so be gentle with my ignorance.
I'm trying to search changelog files for where an open source project dropped a feature I need. I was just wondering if there may be a good set of terms to describe this.

Bugzilla has detailed bug reporting forms. Are design changes also logged using rigorous language?

Its something I can see myself advocating as my own small contribution. (^_^)

答:
I believe the term is deprecated

Deprecation is a status applied to a computer software feature, characteristic, or practice indicating it should be avoided, typically because of it being superseded...

While a deprecated software feature remains in the software its use may raise warning messages recommending alternative practices; deprecated status may also indicate that feature will be removed in the future. Features are deprecated rather than immediately removed to provide backward compatibility and give programmers time to bring affected code into compliance with the new standard...


问:
Must a programmer learn text editors like Emacs and Vim? How important are they?
I have been writing code so far in conventional text editors that come with the OS so far or use an IDE in some cases. I know there are some advanced text editors like Emacs and Vim available solely for the purpose of coders. How important are they really? Should a programmer dealing with PHP, Python etc. learn these editors? What are the advantages that they provide over conventional editors like Notepad++, Scribes etc.?

答:
First things first. VIM is more productive for programming than Eclipse or . Your personal productity in VIM may be abysmal, but the potential cap of VIM is much higher. This is a fact.

VIM is a martial art. It feels unnatural when you first use it. And you can't even make it work. It takes years of practice to gradually become productive. You focus on mastering a little detail at first. Slowly all these bits you master add up until text is flowing effortlessly out of your finger tips onto the screen. Complicated edits that would make your co-worker sigh will jump from your hands before he can finish his exhale. There are few people who can use VIM. Fewer who can use it productivley. And you may never meet a master in your life time. But they are rumored to exist.

VIM is designed to keeep your hands on home-row. Moving your hand from the keyboard to the mouse is demoralizing. It's a gross motor movement. Moving your arm has a phsycological effect that hurts your motivation. Using VIM, someone could bolt your wrists onto the keyboard and you could still easily open up files, split windows, open tabs, build the project, search/replace, change fonts, change colors, etc. And all at lightning speed.

VIM is modal. That means you don't have to do complex key combinations where you hold down control+shift+Key. This hurts your hands in the long run. Instead you execute commands. There is no need for key combos to due to the modal nature.

We store data in our memory like computers do. Our memory can only hold a few values at a time. See how many distinct integers you can hold in your head before they start to slip away. We overcome this human limitation by writing stuff down. If data falls out of our memory we can easily look at what we wrote down to get it back. If your time is spent doing gross motor, physical things you are losing time that could have been spent on processing data in your brain. You want your mind to flow onto the screen without any effort at all. It may not sound like much but VIM's ability to effortlessly transfer what is in your mind to the screen is a BIG productivity boost. It's hard to put in words what I'm trying to say.

VIM supports code completion. Both textual and look-up based. It can pull text from mulitple files. Anything you desire can be had in VIM. Either make it yourself or use something someone else cooked up.

VIM supports goign to definitions with ctags. You can also find all references of an item. Again, anything you desire can be had in VIM.

The scripting of VIM is huge. You can download or create thousands of color schemes and change colors in an instant.  Try to change fonts or colors in Microsoft Visual Studio and it will hang for 20 seconds while it loads data. It won't let you store color schemes and you must spend 30 minutes tweaking your colors and fonts every time you want a change of scenery. In VIM you can set line spacing to zero to fit more lines of code on the screen. I get over 80 lines. Visual studio uses 2 pixels of spacing for every line and you can't adjust it!!! Less lines = more scrolling = less productivity = forced to use small fonts for more lines = eye strain.

Split windows are opened in an instnat in VIM. It's usefull when you need to look at data in one section of the code that's far from the place you are typing (or in a different file). You don't have to spend time resizing windows, or worry about GUI windows overlapping each other and falling behind each other. Un-related code windows can be opened in tabs as to not take up screen space, but allow quick switching.

VIM as an IDE: http://www.youtube.com/watch?v=MQy2rVOf-z0&feature=fvwrel

VIM the revenge: http://www.youtube.com/watch?v=lQNFfhC4QI8

ContentLicense: CC BY-SA 3.0


答:
You don't need to learn Vi or Emacs, you need to learn your tools.
Imagine a sniper who doesn't know well the downsides and capabilities of his rifle, he would not be a good sniper ? Would him ?

So go ahead and find an editor you like, you might like Emacs, Vim, Textmate, Sublime Text... heck, maybe you don't like any of them and you are OK with Nano, but what matters is that you are comfortable with your tools.

Title: Must a programmer learn text editors like Emacs and Vim? How important are they?

Body: I have been writing code so far in conventional text editors that come with the OS so far or use an IDE in some cases. I know there are some advanced text editors like Emacs and Vim available solely for the purpose of coders. How important are they really? Should a programmer dealing with PHP, Python etc. learn these editors? What are the advantages that they provide over conventional editors like Notepad++, Scribes etc.?


答:
Nowadays popularity of various kinds editor worship most likely comes from Pragmatic Programmer book,

or, to be precise, from readers who mindlessly crammed Chapter 3 Basic Tools -> Power Editing -> One Editor but totally missed the key (pragmatic!) takeaway laid out in Preface chapter:

There are no easy answers. There is no such thing as a best solution, be it a tool, a language, or an operating system. There can only be systems that are more appropriate in a particular set of circumstances.

This is where pragmatism comes in. You shouldn't be wedded to any particular technology, but have a broad enough background and experience base to allow you to choose good solutions in particular situations...

You adjust your approach to suit the current circumstances and environment. You judge the relative importance of all the factors affecting a project and use your experience to produce appropriate solutions. And you do this continuously as the work progresses.

If one gets the general understanding like above, this alone makes the book worth reading. Main idea to keep in mind is one that authors stated clearly and unambiguously, "there is no such thing as a best solution".


问:
Decision trees vs. Neural Networks
I'm implementing a machine learning structure to try and predict fraud on financial systems like banks, etc... This means that there is a lot of different data that can be used to train the model eg. card number, card holder name, amount, country, etc...

I'm having trouble deciding which structure is the best for this problem. I have some experience with decision trees but currently I have started to question if a neural network would be better for this kind of problem. Also if any other method would be best please feel free to enlighten me.

Which are the pros and cons of each structure and which structure would be the best for this problem?

Also I'm not sure about this fact but I think decision trees have a great advantage over neural networks in terms of execution speed. This is important because speed is also a key factor in this project.

答:
There are many differences between these two, but in practical terms, there are three main things to consider: speed, interpretability, and accuracy.

Decision Trees

Should be faster once trained (although both algorithms can train slowly depending on exact algorithm and the amount/dimensionality of the data). This is because a decision tree inherently "throws away" the input features that it doesn't find useful, whereas a neural net will use them all unless you do some feature selection as a pre-processing step.

If it is important to understand what the model is doing, the trees are very interpretable.

Only model functions which are axis-parallel splits of the data, which may not be the case.

You probably want to be sure to prune the tree to avoid over-fitting.

Neural Nets

Slower (both for training and classification), and less interpretable.

If your data arrives in a stream, you can do incremental updates with stochastic gradient descent (unlike decision trees, which use inherently batch-learning algorithms).

Can model more arbitrary functions (nonlinear interactions, etc.) and therefore might be more accurate, provided there is enough training data. But it can be prone to over-fitting as well.

You might want to try implementing both and running some experiments on your data to see which is better, and benchmark running times. Or, you could use something like the Weka GUI tooklit with a representative sample of your data to test drive both methods.

It may also be that using "bagging" or "boosting" algorithms with decision trees will improve accuracy while maintaining some simplicity and speed. But in short, if speed and interpretability are really important, then trees are probably where to start. Otherwise, it depends and you'll have some empirical exploration to do.

OwnerDisplayName: Topo

Title: Decision trees vs. Neural Networks

OwnerDisplayName: burr


答:
I don't think there's an explicit term for 'removed functionality'. Others have mentioned 'deprecated', but to my knowledge that means something is slated for removal at a later date and should be avoided.

Your best bet would be to use Removed Functionality or Discontinued Feature.

Title: What's a technical way to describe removed functionality in a software application or framework?

Body:
I'm not trained programmer, so be gentle with my ignorance.
I'm trying to search changelog files for where an open source project dropped a feature I need. I was just wondering if there may be a good set of terms to describe this.

Bugzilla has detailed bug reporting forms. Are design changes also logged using rigorous language?

Its something I can see myself advocating as my own small contribution. (^_^)


答:
There are two terms that i am  currently recalling for functionality that will no longer be supported or used in .NET Framework next release(s):

a) Obsolete - The attribute Obsolete is used to mark types and members of types that should no longer be used. For more detailed info - Obsolete (C# Programming Guide)

b) Function is not supported - Some Visual Basic 6.0 functions are no longer supported in Visual Basic .NET . The functionality that these functions provided can be accomplished using new functions in the .NET Framework; however, the differences in implementation make it too difficult to upgrade automatically.


问:
Add a second developer to the team
In my company, I'm the only developer, but we plan on expanding the team by hiring a second programmer. I know there are a lot of implications to that (especially around source control). I've Googled a lot, but haven't found a good tutorial/article on how to grow the team from one to many developers.

Do you have any resources that we could make use of?

答:
You are probably looking for Onboarding process in software development companies.

In our company, there is a onboarding  process and buddy assignment - to welcome new employee.  It is very important to address any questions and provide new employee with company culture, regulation information.

It is also true that success of your onboarding process will be reflected on new employee's productivity and project success as well.

A sample checklist of onboarding steps are described below:

We have also SharePoint wiki page for each project, where new person may get info on project and related documentation.

To improve onboarding process the HR personal generally conducts a survey to get feedback from new employee.

Title: Add a second developer to the team


问:
What are good source control check-in strategies for large tasks?
The general rule is to keep check-ins small and check-in often. But sometimes the task requires large changes to the underlying framework. Then checking in before compeleting the task will break the project until you check in the finished work.

So what strategies do people use to reduce the risk of losing work, or deciding something you are doing is the wrong approach, then changing your mind after removing the code and trying another approach?

When I can, I'll check-in half done work commented out, or if it compiles and nothing is using new files I'll check them in. The larger the change the more likely I am to branch the project and then merge back when I have everything working again. Another option if the source control system allows is shelf sets, which are basically small branches. So when I finish for the day or come to a decision point, I'll shelve my changes, and then if something catastrophic happens, or I want to come back to that point, I can.

答:
I think the answer is going to vary based on what sort of version control system you're using: centralised (e.g. subversion) or distributed (e.g. git). I don't have any real world experience with using a distributed source control system so my answer is based around what we do with subversion.

If there's a large change in progress which will break our trunk build over a period of time, or that will really disrupt the rest of the team in some other way, then we'll create a branch. I would say though that you should do as much as you can to avoid having to do that - most changes can sit side-by-side with the rest of the code with little effort. For example, you could trigger code paths into the new code (with simple if statements or you could inject the new versions based on config settings if you're using a DI framework). Then when you've finished you just change the the config to the new version, test everything, delete the unused code, test again and finally delete the config setting. You can't always do that but because of the overhead of maintaining a branch I think you should always check if that is possible.

If you do branch I think the mistake that I often see people make is not keeping their branch up-to-date with the trunk. You should be constantly merging changes from trunk into your branch while it exists so that when you've finished the reverse merge of everything back again is fairly trivial.

ContentLicense: CC BY-SA 2.5


问:
How important is an SSL certificate for a website?
I'm bootstrapping my own project, it has a registration/login area (via devise with RoR, properly hashed and salted of course). As I'm using subdomains and I need to access them with iframes (it's justified, really!) I'd need one of those expensive certificates that cover subdomains.

As I'm doing this out of my own time and money, so I'm hesitant to drop a couple of hundreds on a certificate, plus a couple of hours delving into something I haven't tried before. I'm not storing any sensitive information besides the email address and the password. As far as I understand, the only vulnerability happens when a user logs or signs up from an unencrypted network (such as a coffee shop) and someone is listening the network.

Am I being cheap? Is this something I should tackle before releasing into the wild. I probably should mention I have 25,000 users signed up to be notified when I launch, so I'm nervous about it.

答: If you have a unique IP, you might as well get a certificate, particularly if you deal with any data that is even remotely sensitive. Since you can get free trusted certificates from StartSSL, there's really no reason for not having one. </p>


答:
There are at least three reasons why a newly minted programmer might choose to spend some time learning emacs and vi:

tradition: Both vi and emacs have been around since Moses picked up his output on stone tablets. In fact, God himself may have invented either vi or emacs, and the devil the other, but you'll get different answers as to who invented which depending on who you ask. (You've heard that it's a religious argument, right?) At any rate, these two editors have enabled quite a bit of history, and stories and jokes involving them abound. You may feel unable to understand your roots without some knowledge of both. For example:

How many vi users does it take to change a lightbulb?

ne, as long as he doesn’t forget to enter ‘insert’ mode first.*

inertia: There are a lot of people out there who have emacs and/or vi keystrokes burned into their neurons like the high score on a Defender machine. I don't think that anyone would hold up either editor as a shining example of modern user interface design, but since so many people already know the commands, newer editors often build in support for vi and/or emacs commands. MacOS X is perhaps the best example of this: you can use a surprising number of common emacs commands in any Cocoa-based application (unless you're one of those people and install a vi-based input manager). Many IDEs and text editors on all major platforms offer key bindings for vi and/or emacs, and probably will for a long time to come. So, just as you've learned to type on a QWERTY keyboard, you'll probably also pick up some commands derived from an ancient text editor whether you know it or not.

power: I'm not so sure about vi, but it's safe to say that there are very few editors that come close to the power and flexibility available in emacs. Don't like the way something works? You can change it. Don't feel like dropping out of your editor to use the command line? No problem -- you can do everything you need right inside emacs. You'll need to spend a lot of time studying in the swamps of Dagobah to learn to tap into all that power, but some people may find that worthwhile, perhaps even just for its own sake. vi is more like a Leatherman tool hanging on your belt: versatile, always ready, and useable for all sorts of things.

Now then, is it important to learn vi and/or emacs? I'd say that it's useful to know something about both of them, especially so that you know at least a bit if you ever find yourself needing to use them (you might). But not knowing them won't necessarily hold you back. It's much more important to know how to wield the tools that you use daily as effectively as possible.

* That's not a typo -- you'll get it after you spend your first hour with vi.


问:
Would a statically typed alternative to JavaScript on webpages be practical?
Preference for dynamic and static typing is largely a matter of taste, and different people find them more or less suitable in different situations.

My question is, would it be technically possible to have a statically-typed alternative to JavaScript for client-side web page augmentation etc.?

答: Optional static typing was part of ECMAScript's Project Harmony - whether or not it will ever happen in client-side [browser-based] JavaScript is unknown I guess.  See this Wikipedia link: http://en.wikipedia.org/wiki/ECMAScript#Future_development</p>


问:
moving from Windows to Linux
I need to reconcile these 2 facts:

I don't feel comfortable working on Linux;

I need to develop software for Linux.

Some background: I have a 10+ years of programming experience on Windows (almost exclusively C/C++, but some .NET as well), I was a user of FreeBSD at home for about 3 years or so (then had to go back to Windows), and I've never had much luck with Linux. And now I have to develop software for Linux. I need a plan.

On Windows, you can get away with just knowing a programming language, an API you're coding against, your IDE (VisualStudio) and some very basic tools for troubleshooting (Depends, ProcessExplorer, DebugView, WinDbg). Everything else comes naturally.

On Linux, it's a very different story. How the hell would I know what DLL (sorry, Shared Object) would load, if I link to it from Firefox plugin? What's the Linux equivalent of inserting __asm int 3/DebugBreak() in the source and running the program, and then letting the OS call a debugger? Why the hell release builds use something, called appLoader, while debug builds work somehow different? Worst of all: how to provision Linux development environment?

So, taking into account that hatred is usually associated with not knowing enough, what would you recommend? I'm ok with Emacs and GCC. I need to educate myself as a Linux admin/user, and I need to learn proper troubleshooting tools (strace is cool, btw), equivalents to the ones I mentioned above.

Do I need to do Linux from Scratch? Or do I need to just read some books (I've read "UNIX programming environment" by Kernighan and "Advanced Programming..." by Stevens, but I need to learn something more practical)? Or do I need to have some Linux distro on my home computer?

答:
Google "The art of Unix programming" and read it. IMO, your main difficulty is the different philosophy, and that book is excellent reading for this.

It also introduces you to some non-obvious but technically very important differences between *n*x and Windows systems - these being key to understanding why doing things another way makes sense on Linux.

OwnerDisplayName: rincewind

Title: moving from Windows to Linux


问:
Are Design Patterns SuperSet of OOP or SubSet?
Initially I started learning OOP and later started grasping concepts of Design Patterns. I wonder whether it is the Design Pattern which is the SuperSet of OOP or it is the OOP itself.</p>

答: It is possible to program in an object oriented language without using any established design patterns, but it is not possible to use object oriented design patterns in non object oriented languages.  Ergo, I'd say design patterns are a subset of OOP inasmuch as this categorization makes sense.</p>


问:
Unit testing C++: What to test?
TL;DR

Writing good, useful tests is hard, and has a high cost in C++. Can you experienced developers share your rationale on what and when to test?

Long story

I used to do test-driven development, my whole team in fact, but it didn't work well for us. We have many tests, but they never seem to cover the cases where we have actual bugs and regressions - which usually occur when units are interacting, not from their isolated behaviour.

This is often so hard to test on the unit level that we stopped doing TDD (except for components where it really speeds up development), and instead invested more time increasing the integration test coverage. While the small unit tests never caught any real bugs and were basically just maintenance overhead, the integration tests have really been worth the effort.

Now I've inherited a new project, and am wondering how to go about testing it. It's a native C++/OpenGL application, so integration tests are not really an option. But unit testing in C++ is a bit harder than in Java (you have to explicitely make stuff virtual), and the program isn't heavily object oriented, so I can't mock/stub some stuff away.

I don't want to rip apart and OO-ize the whole thing just to write some tests for the sake of writing tests. So I'm asking you: What is it I should write tests for? e.g.:

Functions/Classes that I expect to change frequently?

Functions/Classes that are more difficult to test manually?

Functions/Classes that are easy to test already?

I began to investigate some respectful C++ code bases to see how they go about testing. Right now I'm looking into the Chromium source code, but I'm finding it hard to extract their testing rationale from the code. If anyone has a good example or post on how popular C++ users (guys from the committee, book authors, Google, Facebook, Microsoft, ...) approach this, that'd be extra helpful.

Update

I have searched my way around this site and the web since writing this. Found some good stuff:

When is it appropriate to not unit test?

https://stackoverflow.com/questions/109432/what-not-to-test-when-it-comes-to-unit-testing

http://junit.sourceforge.net/doc/faq/faq.htm#best

Sadly, all of these are rather Java/C# centric. Writing lots of tests in Java/C# is not a big problem, so the benefit usually outweights the costs.

But as I wrote above, it's more difficult in C++. Especially if your code base is not-so-OO, you have to severely mess things up to get a good unit test coverage. For instance: The application I inherited has a Graphics name space that is a thin layer above OpenGL. In order to test any of the entities - which all use its functions directly - I'd have to turn this into an interface and a class and inject it in all the entities. That's just one example.

So when answering this question, please keep in mind that I have to make a rather big investment for writing tests.

答:
Well, Unit Testing is only one part. Integration tests help you with the problem of your team.  Integration Tests can be written for all kinds of applications, also for native and OpenGL applications. You should check out "Growing Object Oriented Software Guided by Tests" by Steve Freemann and Nat Pryce (e.g. http://www.amazon.com/Growing-Object-Oriented-Software-Guided-Signature/dp/0321503627). It leads you step by step through the development of an application with GUI and network communication.

Testing Software that was not test driven is another story. Check Michael Feathers "Working Effectively with Legacy Code" (http://www.amazon.com/Working-Effectively-Legacy-Michael-Feathers/dp/0131177052).

Title: Unit testing C++: What to test?


问:
Refactoring options - multiple methods in same class or into separate classes
we have some API which will be called either by client A, B, C or D

Current code

```<code>doSomething(String client){

if (client.equals("A")){
...
}
else if (client.equals("B")){
...
}
</code>```

Proposed refactoring 1

separate into multiple methods and have each client call the dedicated method such as

```<code>doSomethingForClientA()

doSomethingForClientB()
</code>```

we need this because internally each method will call other private methods defined in the same class

Proposed refactoring 2

Use strategy (or template) pattern and separate into multiple classes for the clients to call

the method call from client remains

```<code>doSomething()
</code>```

Which approach is better in the long run? Is there any design pattern to help with option 1 ?
or a 3rd option?

答:
Proposed refactoring 2 is better in the long run.

This will allow you to extend additional functionality for additional (unforeseen ) client types later, without modifying tested parts of code, for already existing clients.


问:
Release Management versions control?
We recently experienced a deployment issue where it turned out that the version objects were not in sync in one of the environments.

We have a large database group and different teams have different responsibilities and ownerships - I might code on schema X, Y, Z but I also will have dependancies on objects owned by other groups. This is the same no matter what technology - java libraries having different versions and what not.

My aim is to have something be in a webpage or a database table or something that I can see that for object A I have version X installed in Production, X + 1 in UAT and QA, and X + 2 installed in DEV.

How do other folks handle this? How do you pick up version changes? Do you rely on SCM? Build numbers? Hash value of the source code?

I'm interested in managing version consistency across technologies - java to db for instance.

答:
From what I see, you are referring to configuration management, however, if there are different parts to your system and you want to put them in version control to keep them consistent, the best I can think of is:

A) To maintain a file (in XML, JSON or whatever serialization format you like) where you describe what version of each thing you need for each component.

```<code>{
  "JAVA": ">1.7.0_05",
  "MYSQL": ">=5.0.28",
  ...
}
</code>```

Have each component import this file into constants and assert their values against the environment they are running on, there are ways to get this information from wherever your application is deployed. If they don't match the desired values (or value ranges even), throw a warning.

B) If you have different components and you use something like Mercurial for version control, then you could use something like the subrepository feature, where your top/manager repository essentially does configuration management, this is, the top repository will keep track what versions of each component are being used across in a given moment in time. Picture this:

```<code>project_x #250 <- top repository at changeset 250
|--component_a #1232 <-component a at changeset 1232
|--component_b #23 <- component b at changeset 23
|--component_c #32 <- component c at changeset 32
</code>```

And then with component_a's new version (say 1233) you need a new version of component_c, but not component_b, so you update component_a and component_c and commit project_x to a new version that records those changes

```<code>project_x #251 <- top repository at changeset 251, recording 1233 and 33 for a and c
|--component_a #1233 <-component a now at at changeset 1233
|--component_b #23 <- component b at changeset 23
|--component_c #33 <- component c now at changeset 33
</code>```

Keep in mind that it might not be the best idea to store java or mysql itself in version control, but as mentioned earlier, this would be effective configuration management for project-independent components.

If you want to keep track of Java, MySQL, etc, "A)" provides a good mechanism to assert that configuration.

The "project_x" repo can have a development branch and a production branch where it tracks different component configurations.

In summary

Have a manifest to which you can code against and assert your configuration, and for your project independant components you can use Mercurial subrepos (or git submodules) to keep track of the version configuration among them.

Title: Release Management versions control?

Body:
From what I see, you are referring to configuration management, however, if there are different parts to your system and you want to put them in version control to keep them consistent, the best I can think of is:

A) To maintain a file (in XML, JSON or whatever serialization format you like) where you describe what version of each thing you need for each component.

{
  "JAVA": ">1.7.0_05",
  "MYSQL": ">=5.0.28",
  ...
}

Have each component import this file into constants and assert their values against the environment they are running on, there are ways to get this information from wherever your application is deployed. If they don't match the desired values (or value ranges even), throw a warning.

B) If you have different components and you use something like Mercurial for version control, then you could use something like the subrepository feature, where your top/manager repository essentially does configuration management, this is, the top repository will keep track what versions of each component are being used across in a given moment in time. Picture this:

project_x #250 <- top repository at changeset 250
|--component_a #1232 <-component a at changeset 1232
|--component_b #23 <- component b at changeset 23
|--component_c #32 <- component c at changeset 32

And then with component_a's new version (say 1233) you need a new version of component_c, but not component_b, so you update component_a and component_c and commit project_x to a new version that records those changes

project_x #251 <- top repository at changeset 251, recording 1233 and 33 for a and c
|--component_a #1233 <-component a now at at changeset 1233
|--component_b #23 <- component b at changeset 23
|--component_c #33 <- component c now at changeset 33

Keep in mind that it might not be the best idea to store java or mysql itself in version control, but as mentioned earlier, this would be effective configuration management for project-independent components.

If you want to keep track of Java, MySQL, etc, "A)" provides a good mechanism to assert that configuration.

The "project_x" repo can have a development branch and a production branch where it tracks different component configurations.

In summary

Have a manifest to which you can code against and assert your configuration, and for your project independant components you can use Mercurial subrepos (or git submodules) to keep track of the version configuration among them.


问:
Why are the arguments for substring functions mismatched?
In many languages, the substring function works like this:

substring(startIndex, endIndex)

returns the substring from startIndex until endIndex-1 (if you view startIndex and endIndex as 0-based) / from startIndex+1 to endIndex (1-based)

This is confusing. I understand that the two parameters can be interpreted as "startIndex" and "length of the substring", but in my opinion that is still confusing and even in this case, startIndex is 0-based while length is 1-based.

Why not stick to one convention for both the function arguments? and why do  newer languages like ruby and python continue to stick to this standard?

答:
The second argument is not the "length of the substring", that only works if you start at the very beginning of the string. The point is that specifying "from".."to" is linguistically ambiguous: you name two limit values, but do you want those two values themselves included in the extracted range or not?
In normal parlance, there isn't a strong conventional preference: "I knew her from first to fourth grade" means "for four years", but "training is from one to three" means "two hours", not three.

Therefore, it would be a major source of confusion if the indices referred to characters in a string. What they really refer to is the positions between the characters: 0 means "before the string", 1 means "after the first character", 2 means "after the second character" etc. Therefore, s.substring(0,2) means "The first two characters of s", unambiguously. (The fact that endIndex - startIndex == length(extract) is admittedly a nice bonus.)


问:
How to determine whether Design Pattern is implemented correctly?
I am successfully able to scale all my old applications which were not using documented Design Patterns. Whatever pattern it is I don't know. To a large extent, I only felt a need to use simple OOP concepts.

The Design Patterns  concept is complex and hard to understand. When implemented, how to determine whether the implementation is correct and the application possess real loose coupling?

答:
The answer is actually the purpose that you want to write design patterns from start. Why do you want flexibility for?

That is change; requirements change. Try to change something in your requirements that reflects in code change and see how easy/difficult is to do that.


答: The second option is better. Use the Strategy Pattern. Of course you can use still use doSomethingForClientX() in the private functions if you can't think of a better name. Use the template pattern only if your sequence of operations (private function calls) remains the same.

Title: Refactoring options - multiple methods in same class or into separate classes

Body:
we have some API which will be called either by client A, B, C or D

Current code

```<code>doSomething(String client){

if (client.equals("A")){
...
}
else if (client.equals("B")){
...
}
</code>```

Proposed refactoring 1

separate into multiple methods and have each client call the dedicated method such as

```<code>doSomethingForClientA()

doSomethingForClientB()
</code>```

we need this because internally each method will call other private methods defined in the same class

Proposed refactoring 2

Use strategy (or template) pattern and separate into multiple classes for the clients to call

the method call from client remains

```<code>doSomething()
</code>```

Which approach is better in the long run? Is there any design pattern to help with option 1 ?
or a 3rd option?


问:
Using a SetProperty method to prevent accidental changes to a property
Is it good/bad practice to do the following:

```<code>public class MyClass {
  public MyType MyProperty { get; private set; }

  public void SetMyProperty(MyType myProperty) {
    MyProperty = myProperty;
  }
}
</code>```

My intention is to prevent MyProperty from being accidentally changed outside the class. However, it can be changed if needed.

Also, if MyType is a reference type, then will the private set prevent, for example:

```<code>instanceOfMyClass.MyProperty.SomeField = 2;
</code>```

In other words, will it make MyProperty and all its members readonly, or just the reference to MyProperty?

Sorry if this seems an unintelligent question; I'm afraid I'm a beginner.

答:
Providing a getter still allows the properties of the class to be changed. I would clone the instance if you'd want to avoid that</p>

```<code>private MyType _myProperty;
public MyType MyProperty { get { return new MyType(_myProperty); } set { _myProperty = value; } }
</code>```

Body:
Providing a getter still allows the properties of the class to be changed. I would clone the instance if you'd want to avoid that

private MyType _myProperty;
public MyType MyProperty { get { return new MyType(_myProperty); } set { _myProperty = value; } }


问:
Is it worth moving from Microsoft tech to Linux, NodeJS & other open source frameworks to save money for a start-up?
I am currently getting involved in a startup, I am the only developer involved at the moment, and the other guys are leaving all the tech decisions up to me at the moment.

For my day job I work at a software house that uses Microsoft tech on a day to day basis, we utilise .NET, SqlServer, Windows Server etc. However, I realise that as a startup we need to keep costs down, and after having a brief look at the cost of hosting for Windows I was shocked to see some of the prices for a dedicated server. The cheapest I found was £100 a month. Also if the business needs to scale in the future and we end up needing multiple servers, we could end up shelling out £10's of £000's a year in SQL Server / Windows Server licenses etc.

I then had a quick look at the price of Linux hosting for a dedicated server and saw the price was waaaaaay lower than windows hosting. One place was offering a machine with 2 cores for less than £20 a month.

This got me thinking maybe the way to go is open source on Linux.

As I write a lot of Javascript at work (I'm working on a single page backbone app at the moment), I thought maybe NodeJS and a web framework like Express would be cool to use. I then thought that instead of using SQL why not use an open source NoSQL database like MongoDB, which has great support on NodeJS?

My only concern is that some of the work the application is going to do is going to be dynamically building images and various other image related stuff, i.e. stuff that is quite CPU heavy - so I'm thinking of maybe writing anything CPU heavy in C++ and consuming it as a module in Node.

That's the background - but basically is Linux a good match for:

Hosting a NodeJS/Express site?

Compiling C++ node modules?

Using a NoSQL DB like MongoDB?

And is it a good idea to move to these unfamiliar technologies to save money?

3 MONTH UPDATE

I've been working on this for the past few months now so thought I would give an update in case anyone is interested.

In the end I decided against using a NodeJS & Linux stack for the simple reason of time. I am doing this startup on the side, so I am working 9 hour days, then going home and working until late on the startup. While working in this way I obviously need to be as efficient with my time as possible, or I will never end up shipping the product.

After taking some of the advice on this thread I did apply for Microsoft BizSpark, and was accepted. This means I now have access to Visual Studio license, Windows Server license etc, all for free. Which is awesome. Hopefully by the time we are required to begin paying for everything we will be turning over enough that will make it a non-issue.

Do not think I am only using Microsoft tech, however, as I have tried to use open source stuff where possible. The main place I have done this is my data layer, where I have decided to use PostgreSQL and MongoDB. I am also using BackboneJS on my front end.

Below is a summary of the tech/frameworks I am currently using:

Standard DB stuff: PostreSQL

Logging & Data Store: MongoDB

ORM: Entity Framework 5

Core libraries: .NET (C#)

Web Framework: ASP.NET MVC3

UI: Razor view engine / BackboneJS

答:
"First, make it. Then, make it right. Then, make it good."

I'd suggest launching as early as possible, on technology that makes that possible. If you're concerned about not having options later on, code in such a way that swapping out modules and slowly migrating to something else is possible. Just remember that the business has to get popular enough to warrant it, and you have to have a working product soon.


问:
What's the most important, useful or enlightening thing you learnt in the last 12 months?
A lot of people in the coding community talk about continuous improvement, deliberate practice and so-on - but when they talk about their current practices it's almost like they 'sprang fully formed from the loins of Zeus' because you don't hear about how their opinions changed over time or what they learnt recently.

Every now and then though I go to a talk, or read a book, or talk to someone and they open up a bit more and I find that I learn a lot from these insights.

So, if you had to pick one thing from the last 12 months that you learnt what would it be?

答:
Here's my answer to my own question:

About a year ago it clicked that automated acceptance tests needed to be not automated versions of the tests that our testers would have done manually. Focussing on tests against single specifications rather than trying to hit as much as possible in a single pass made the tests much simpler, easier to read and also helps to encourage incremental delivery.


答:
How configuration management differs from environment to environment, language to language. I can give a concrete example on how things are handled in deployments that I manage, where most of the software is written in python.

In the Python world, individual libraries are distributed as eggs, and list their dependcenies in the package metadata:

```<code>  install_requires=[
      'setuptools',
      'PyRTF',
      'pisa >= 3.0.29',
      'reportlab >= 2.2',
      'html5lib == 0.11.1',
      'pyPdf == 1.12',
  ],
</code>```

In the above example some package versions are left un-pinned, others specify a minimum, and the last two are pinned to exact versions only. The deployment tool then has the responsibility of picking versions where no exact versions have been specified to match the constraints set for this egg.

We use buildout to manage our deployments; it is a build system that uses python packages called recipes to construct software for us. It's configuration files easily let you include other configuration files letting you delegate responsibilities and specify different configurations for different deployment scenarios with ease.

Within buildout, we generally pin the exact versions for a release in a versions list:

```<code>[buildout]
versions = versions

[versions]
setuptools = 0.6c11
PyRTF = 0.45
pisa = 3.0.33
# etc.
</code>```

A development.cfg configuration could override specific versions, clear the pins for others, or pull in a whole new set of versions by also including the configuration for a large framework version upgrade. We often use a staging.cfg to roll out test configurations to the staging server so the customer can sign off on test plans before changes are rolled out to production.

It helps tremendously here that large frameworks such as Plone publish version lists for the python packages that make up the framework; this let's you upgrade your application to use a new release of the framework, or just upgrade individual packages using a local override.

Finally, how we discover new package releases also depends on whom releases the packages; the Python Package index (PyPI) publishes an RSS feed of new packages, various projects have their own news channels, and for internal updates we use similar mechanisms.

It is important for us to keep our buildouts repeatable and predictable however, so we only upgrade packages when we actually need the changes in the newer versions and have tested the upgrade; but thanks to buildout configurations, setting up a CI server such as Jenkins for various setups (production, staging, project milestone, etc) is very easy. As long as your test suite has good test coverage, you could even automate pulling in new versions of packages from other teams within your organisation.

Title: Release Management versions control?

Body:
We recently experienced a deployment issue where it turned out that the version objects were not in sync in one of the environments.

We have a large database group and different teams have different responsibilities and ownerships - I might code on schema X, Y, Z but I also will have dependancies on objects owned by other groups. This is the same no matter what technology - java libraries having different versions and what not.

My aim is to have something be in a webpage or a database table or something that I can see that for object A I have version X installed in Production, X + 1 in UAT and QA, and X + 2 installed in DEV.

How do other folks handle this? How do you pick up version changes? Do you rely on SCM? Build numbers? Hash value of the source code?

I'm interested in managing version consistency across technologies - java to db for instance.

Body:
How configuration management differs from environment to environment, language to language. I can give a concrete example on how things are handled in deployments that I manage, where most of the software is written in python.

In the Python world, individual libraries are distributed as eggs, and list their dependcenies in the package metadata:

  install_requires=[
      'setuptools',
      'PyRTF',
      'pisa >= 3.0.29',
      'reportlab >= 2.2',
      'html5lib == 0.11.1',
      'pyPdf == 1.12',
  ],

In the above example some package versions are left un-pinned, others specify a minimum, and the last two are pinned to exact versions only. The deployment tool then has the responsibility of picking versions where no exact versions have been specified to match the constraints set for this egg.

We use buildout to manage our deployments; it is a build system that uses python packages called recipes to construct software for us. It's configuration files easily let you include other configuration files letting you delegate responsibilities and specify different configurations for different deployment scenarios with ease.

Within buildout, we generally pin the exact versions for a release in a versions list:

[buildout]
versions = versions

[versions]
setuptools = 0.6c11
PyRTF = 0.45
pisa = 3.0.33
# etc.

A development.cfg configuration could override specific versions, clear the pins for others, or pull in a whole new set of versions by also including the configuration for a large framework version upgrade. We often use a staging.cfg to roll out test configurations to the staging server so the customer can sign off on test plans before changes are rolled out to production.

It helps tremendously here that large frameworks such as Plone publish version lists for the python packages that make up the framework; this let's you upgrade your application to use a new release of the framework, or just upgrade individual packages using a local override.

Finally, how we discover new package releases also depends on whom releases the packages; the Python Package index (PyPI) publishes an RSS feed of new packages, various projects have their own news channels, and for internal updates we use similar mechanisms.

It is important for us to keep our buildouts repeatable and predictable however, so we only upgrade packages when we actually need the changes in the newer versions and have tested the upgrade; but thanks to buildout configurations, setting up a CI server such as Jenkins for various setups (production, staging, project milestone, etc) is very easy. As long as your test suite has good test coverage, you could even automate pulling in new versions of packages from other teams within your organisation.


答:
[extending my previous comment]

You might move these special codes to wrapper classes assigned to the client types, create them when the client enters, and use their functions.

```<code>interface ClientWrapper {
  void doSomething();
}

class ClientWrapperForA implements ClientWrapper {
  void doSomething() {
    // do that something for client A
  }
}
</code>```

You can create configurable, singleton ClientWrapperFactory, the config is a map with ["A" - "wrapper.class.name.for.clientA"] pairs, and creates the instance by calling Class.forName(cfgMap.get("A")).newInstance(), store the current wrapper instance in the session context (or "get" it all the time, and use lazy creation) - I suppose you talk about a web application. Adding a new client means only extending this map with a new item, and create the appropriate wrapper class.

Body:
[extending my previous comment]

You might move these special codes to wrapper classes assigned to the client types, create them when the client enters, and use their functions.

interface ClientWrapper {
  void doSomething();
}

class ClientWrapperForA implements ClientWrapper {
  void doSomething() {
    // do that something for client A
  }
}

You can create configurable, singleton ClientWrapperFactory, the config is a map with ["A" - "wrapper.class.name.for.clientA"] pairs, and creates the instance by calling Class.forName(cfgMap.get("A")).newInstance(), store the current wrapper instance in the session context (or "get" it all the time, and use lazy creation) - I suppose you talk about a web application. Adding a new client means only extending this map with a new item, and create the appropriate wrapper class.


答:
Using design patterns is a preventive action. You use design paterns to ease your work when you are scaling the application later. Of course, to ease your work later you must do a bit more work now. so the real question is how much change can you expect in the future and what this change is. If you do not need scalability and flexibility  you can do away with design patterns.

Design patterns are themselves an implementation of Object Oriented Design Principles. As long as you follow these principles your applications are going to be flexible and scalable; even if you dont really have an actual design pattern. As Joachim Sauer has commented above they are common solutions to common problems.

Title: How to determine whether Design Pattern is implemented correctly?

Body:
I am successfully able to scale all my old applications which were not using documented Design Patterns. Whatever pattern it is I don't know. To a large extent, I only felt a need to use simple OOP concepts.

The Design Patterns  concept is complex and hard to understand. When implemented, how to determine whether the implementation is correct and the application possess real loose coupling?


答:
You mention both design patterns and coupling. These are separate concepts so I'll deal with them separately. The only real connection is that design patterns tend to promote loose coupling (since it's a major aspect of good design).

Design Patterns

The concept of Design Patterns is actually quite simple: They're just a set of templates of how to deal various common problems. There are 2 main reasons that they are popular:

They are 'proven': they have been used before many times and the benefits/drawbacks of each are generally known, in particular any subtle issues that might cause big problems are known.

They provide a common set of terminology, and so enable easier communication. If someone says "class X plays the role of the observer in the observer pattern" then developers who are familiar with the pattern can immediately grasp what's going on.

How do you know that you've implemented it correctly? That's a tricky one. For most patterns it's simple - you've either grokked it or you haven't. Some patterns are less clearly-defined than others - e.g. model-view-controller. Patterns like that are better used as general guidelines. The specifics of how you implement it are less important than understanding the reasons that the pattern exists and what it's meant to accomplish.

Design patterns aren't 'the one true way'. Often you'll either need to adapt them for your specific purposes, or sometimes there just won't be any patterns which fit the requirements. Forcing a design pattern where it doesn't fit is a bad idea; it's like using a really good hammer when what you actually want is a screwdriver.

Coupling

This is a really important idea in computer science. Since requirements for most software projects change over time (sometimes significantly) then the ability for a design to cope with changes is important. Coupling is basically the measure of "how hard would it be to swap out this component for another one?" The 'component' could be a method, class, package, library, etc.

There are various types of coupling listed in this Wikipedia article.


问:
Python mutable default argument: Why?
I know that default arguments are created at the function initialisation time and not every time the function is called.  See the following code:

```<code>def ook (item, lst=[]):
    lst.append(item)
    print 'ook', lst

def eek (item, lst=None):
    if lst is None: lst = []
    lst.append(item)
    print 'eek', lst

max = 3
for x in xrange(max):
    ook(x)

for x in xrange(max):
    eek(x)
</code>```

What I do not get is why this was implemented this way.  What benefits does this behaviour offers over an initialisation at each call time?

答:
What benefits does this behaviour offers over an initialisation at each call time?

It lets you select the behavior you want, as you demonstrated in your example. So if you want that the default argument is immutable, you use an immutable value, such as None or 1. If you want to make the default argument mutable, you use something mutable, such as []. It's just flexibility, albeit admittedly, it can bite if you don't know it.

Title: Python mutable default argument: Why?


问:
Why does XMLHttpRequest not seem to follow a naming convention?
I've been working with the XMLHttpRequest object in JavaScript recently, and I couldn't help but notice that the casing of this name makes no sense.  Why is 'XML' all in caps while 'Http' is not?  They're both acronyms!

Surely it'd make more sense for the name to be one of the following:

XmlHttpRequest (PascalCase, best practice for class names in JavaScript)

xmlHttpRequest (camelCase, also common though not for classes)

XMLHTTPRequest (caps-for-acronyms, rarely used in programming?)

I'm sure there must be some reason and I'd hate to think it's now set in stone just because no one questioned this at the time.  Is there another naming convention that I'm unaware of?

答:
Interestingly enough, Microsoft first called it IXMLHTTPRequest when it was first added to the MSXML library.

It was Mozilla that used the name XMLHttpRequest when it added the concept into Gecko, implementing the idea to mimic the MS interface. It has since become the defacto standard, tying all other implementations to Mozilla's decision.

You'd have to go spelunking in the Mozilla Bugzilla to see if you can find any reasoning for the caps change there, but I suspect that not much thought went into it and the lowercasing of the ttp part is accidental.

This is corroborated by the misspelling of the Microsoft interface in the nsIXMLHttpRequest interface definition (earliest revision in the Mozilla Mercurial repository):

Mozilla's XMLHttpRequest is modelled after Microsoft's IXMLHttpRequest
  object. The goal has been to make Mozilla's version match Microsoft's
  version as closely as possible, but there are bound to be some differences.


答:
One way to put it is that the lst.append(item) doesn't mutate the lst parameter. lst still references the same list. It's just that the content of that list has been mutated.

Basically, Python doesn't have (that I recall) any constant or immutable variables at all - but it does have some constant, immutable types. You can't modify an integer value, you can only replace it. But you can modify the content of a list without replacing it.

Like an integer, you can't modify a reference, you can only replace it. But you can modify the content of the object being referenced.

As for creating the default object once, I imagine that's mostly as an optimisation, to save on object-creation and garbage collection overheads.

Title: Python mutable default argument: Why?

Body:
I know that default arguments are created at the function initialisation time and not every time the function is called.  See the following code:

```<code>def ook (item, lst=[]):
    lst.append(item)
    print 'ook', lst

def eek (item, lst=None):
    if lst is None: lst = []
    lst.append(item)
    print 'eek', lst

max = 3
for x in xrange(max):
    ook(x)

for x in xrange(max):
    eek(x)
</code>```

What I do not get is why this was implemented this way.  What benefits does this behaviour offers over an initialisation at each call time?


答:
After learning some Clojure, I started to realize the usefulness of functional programming, and my Java coding style has been heavily affected by that. Contrary to popular belief, a functional programming language is not an absolute prerequisite for doing some functional programming.

It's possible to incorporate quite a few elements of functional programming into an imperative language such as Java, and even if it's not always idiomatic, it can be highly beneficial in some problems. For example, anonymous classes are roughly equal to closures, as described in wikipedia. Lazy evaluation should be a norm rather than something unusual. Immutability can hardly be overused. Just get over the (almost) obsolete idea that constructing new objects instead of mutating existing ones is expensive because of GC and heap consumption - in 99.9 % of cases it's simply not relevant. In fact, parallel processing can flip even the efficiency argument other way round: creating new immutable objects can be cheaper than mutating existing ones, because you get rid of locking.

More info on doing FP in pure Java here, here, here and here.

Title: What's the most important, useful or enlightening thing you learnt in the last 12 months?

Body:
A lot of people in the coding community talk about continuous improvement, deliberate practice and so-on - but when they talk about their current practices it's almost like they 'sprang fully formed from the loins of Zeus' because you don't hear about how their opinions changed over time or what they learnt recently.

Every now and then though I go to a talk, or read a book, or talk to someone and they open up a bit more and I find that I learn a lot from these insights.

So, if you had to pick one thing from the last 12 months that you learnt what would it be?


问:
How to support mixed grammars?
I am currently writing a grammar for a programming language (PowerBuilder) and I am also collecting documentation about parsing and compilers creation.

Now I would like to add in my grammar (that looks roughly like Visual Basic) the possibility to handle embedded SQL statements that are supported inline by the language (with the usage of binding variables like select foo into :ls_bar from baz where col=:ls_criteria;). As the embedded SQL is regular SQL syntax, I would not complexify my existing grammar but instead adapt an existing SQL-92 grammar to my needs and use it on these SQL blocks.

The parser generator that I am mainly using (AntLR) has some possibilities to support mixed or "island" grammars as described in that article or another.

I would like to compare these techniques with AntLR with others tools like Lex/Yacc, Flex, JFlex, that I used while playing with several simple language designs described in different CS courses available online.

Could you point me to examples of implementations of parsers that support mixed grammars?

答: PEGs and all the other lexerless approaches allow to mix any kind of grammars. See Katahdin for an inspiration.</p>

Title: How to support mixed grammars?


答:
Even if you have a superb team, and competent management for that team, your job is still not safe. Upper management can still do foolish things, like disband your entire Directorate.

In short: politics matters, and sometimes the politics that affect you, you cannot control.


答:
I think the reason is implementation simplicity. Let me elaborate.

The default value of the function is an expression that you need to evaluate. In your case it is a simple expression that does not depend on the closure, but it can be something that contains free variables - def ook(item, lst = something.defaultList()). If you are to design Python, you will have a choice - do you evaluate it once when the function is defined or every time when the function is called. Python chooses the first (unlike Ruby, which goes with the second option).

There are some benefits for this.

First, you get some speed and memory boosts. In most cases you will have immutable default arguments and Python can construct them just once, instead of on every function call. This saves (some) memory and time. Of course, it doesn't work quite well with mutable values, but you know how you can go around.

Another benefit is the simplicity. It's quite easy to understand how the expression is evaluated - it uses the lexical scope when the function is defined. If they went the other way, the lexical scope might change between the definition and the invocation and make it a bit harder to debug. Python goes a long way to be extremely straightforward in those cases.

Title: Python mutable default argument: Why?


问:
Appropriate programming language to design music software
I want to design a software for my musical instrument which is a rhythmic one (there is no melody).
All I want these software to do is :

make the user able to compose music

play what user has composed

for that purpose I need to record diffrent sounds of that instrument and match each sign with the appropriate sound .

Which programming language is adequate for this purpose ?

答:
You should probably check out Overtone:

Overtone is an open source audio environment being created to explore
  musical ideas from synthesis and sampling to instrument building,
  live-coding and collaborative jamming. We use the SuperCollider synth
  server as the audio engine, with Clojure being used to develop the
  APIs and the application. Synthesizers, effects, analyzers and musical
  generators can be programmed in Clojure.

There's a nice video demonstration of Overtone being used for live-coding music and instrument synthesis.

Overtone uses SuperCollider under the hood.

One of the nice things about Overtone is that while it provides an environment for music programming, the language used (Clojure) is a general purpose language. So you aren't forced to learn a new language which is only useful for the music parts.


答: If you want to combine sound with a user interface of your own design (possibly even your own hardware), take a look at Processing. It's a media-rich language that's meant to be easy to pick up, and the culture that's grown up around the language seems to encourage beautiful projects. Take a look at some of the things people have created, many of which involve sound.

Title: Appropriate programming language to design music software

Body:
I want to design a software for my musical instrument which is a rhythmic one (there is no melody).
All I want these software to do is :

make the user able to compose music

play what user has composed

for that purpose I need to record diffrent sounds of that instrument and match each sign with the appropriate sound .

Which programming language is adequate for this purpose ?


答:
Neither.

Design patterns are just constructs to simplify communication about programming by providing a common lexicon for common code layouts (or paradigms or models or ...)

I can (and have!) write a facade or a singleton in a non-OO language.

Some have argued that design patterns are just ways to make up for feature deficiencies within the core language itself.  I think that's a bit of an exaggeration, but it does help keep design patterns in their proper perspective.  They're just another tool to aid in communication and design; they don't belong up on a pedestal to be worshipped.

Title: Are Design Patterns SuperSet of OOP or SubSet?

Body: Initially I started learning OOP and later started grasping concepts of Design Patterns. I wonder whether it is the Design Pattern which is the SuperSet of OOP or it is the OOP itself.</p>


问:
What's the career path for a developer who doesn't like management?
If you're developer (Senior or Lead Developer) and you'd rather stay with code/design than pursue a management career, what are the available career paths at your company, or any you've heard of? How far can you go?

Is it possible to continue being a geek until you bite the dust or is that too naive?

Are people like Uncle Bob for example still considered developers, as they claim?

答: At my company, the management and individual contributor tracks are separate and mostly parallel.  Individual contributors can rise very high in the company (up to Technical Fellow) without being a people manager.  It helps to partially avoid the Peter Principle, though never completely.</p>


答:
This is really good question with presented analysis!

If you look for a maintainable and extensible code, of course use the option 2!.
It is one of the examples where Dependency Inversion Principle is applied.

As a reference i would suggest to look at  S.O.L.I.D.principles. In addition, there is a good reply on somewhat similar question - Programming SOLID Principles


问:
DDD, Saga & Event-sourcing: Can a Compensate Action simply be a delete on the event store?
I realize the above question probably raises a few 'what??'s, but let me try to explain :

I'm trying to wrap my head on a couple of related concepts, basically the Saga-pattern ( http://www.rgoarchitects.com/Files/SOAPatterns/Saga.pdf) in combination with Event-sourcing (A DDD-concept: http://en.wikipedia.org/wiki/Domain-driven_design)

A good post that wraps it together:
https://blog.jonathanoliver.com/cqrs-sagas-with-event-sourcing-part-ii-of-ii/

I'm getting to the question in a minute, but I think I have to try to summarize what I understand of it first (which might well be wrong, so please correct if that's the case) since this might well impact why I'm asking the question to begin with:

The Saga pattern is a sort of broker that given an action (end-user, automated, etc. essentially anything that is going to change data) divides that action up in business activities and sends each of these activities as messages to a Message Bus which in turn sends it to the respective aggregate roots to be taken care of.

These aggregate roots can operate completely autonomously (nice separation of concerns, great scalability, etc. )

A Saga-instance itself doesn't contain any business logic, that is contained in the aggregate roots it sends activities to. The only 'logic' contained in the Saga is 'process'-logic, (often implemented as a Statemachine), which determines based on actions received (as well as follow-up events) what to do (i.e: what activities to send)

The Saga-patterns implements a kind of distributed transaction pattern. I.e: when one of the aggregate roots (which again work autonomously, without knowing of eachothers existense) fails, the entire action might have to be rolled back.

This is implemented by having all aggregate roots, upon completion of their activity report back to the Saga. (In case of success as well as error)

In case all aggregate roots return a success, the internal statemachine if the Saga determines what to do next (or decides it's  done)

In case of failure, the Saga issues to all aggregate roots that took part in the last action a so called Compensation Action, i.e: an action to undo the last action each of the aggregate roots did.

This might be simply doing a 'Minus 1 vote' if the action was "plus 1 vote' but it could be more complicated like restoring a blogpost to it's previous version.

Event-sourcing (see the blogpost combining the two) aims to externalize saving the results of each of the activities that each of the aggregate roots undertake to a centralized Event Store (the changes are called 'events' in this context)

This Event store is the 'single version of the truth' and can be use to replay the state of all entities simply by iterating the events stored (essentially like an event log)

Combining the two (i.e: letting aggregate roots use Event-sourcing to outsource saving their changes before reporting back to the Saga) enables lots of nice possibilities, one of which concerns my question...

I felt I needed to get this off of my shoulder, since it's a lot to grasp in one go. Given this context/mindset (again, please correct if wrong)

the question: When an aggregate root receives a Compensate Action and if that aggregate root has outsourced it's state-changes using Event-sourcing, wouldn't the Compensate Action in all situations just be a delete of the last event in the Event Store for that given Aggregate Root? (Assuming the persist-implementation allows deletes)

That would make sense to me a lot (and would be another great benefit of this combination) but as I said I might be making these assumptions based on a incorrect/incomplete understanding of these concepts.

I hope this didn't get too long-winded.

Thanks.

答:
You shouldn't delete the events from your event store. These represent something that happened.
If something happens now, then you should know it too, therefore add an event that will force your aggregate to go back to some previous state. That's a pity to delete information from your database.

think about the example of the cart from greg young and the removed items. May be tomorrow the information of compensating action might be of any value..

As for the saga, every thing is correct, as far as I know myself. You should think of the saga as of a state machine. It does only that.

It is a Command the saga is issuing to tell the aggregate to do something. Of this action there will be an event.
This event might be the corrective action you need, or might need to be  denormalised in a view so that some user will see it to decide what to do.

It depends on your business rules. Either, there is an easy fix : the aggregate root knows that in such case , you do that, or the choice is too complex to be done programmatically ( development cost are too high) and therefore, you might propose this to some user, who might choose between different action.
Everything depend on the context of the compensating action. This is pure business rules. What should we do in this case or that case. This is something to ask your domain expert, and then choose with him, if it is better to develop an automatic solution or if the solution is to ask the user Ronald R., because he is the one to answer this question usually.

OwnerDisplayName: Geert-Jan

ContentLicense: CC BY-SA 4.0


问:
YAML: translating free-flowing text from XML
I'm studying YAML as a replacement for XML, but I'm experiencing difficulties when dealing with elements containing free-flowing text with embedded elements.  For instance, the following XML document:

```<code>    <text>
    This is an example text, spanning multiple lines, and it has embedded elements
    like this and <b>this</b>.  There is also a list:
         <quote>
            <text>The text of the quote, spanning multiple lines, and it has
            embedded elements like <c p="value">this</c> and <b>this</b></text>
            <author>The Author of this quote</author>
        </quote>
    Text continues here.
    </text>
</code>```

I don't know how to convert the embedded elements in YAML.  My understanding is that the above XML document segment translates to something like this (except for the embedded elements):

```<code>    text: >
            This is an example text, spanning multiple lines, and it has embedded
            elements like this and <b>this</b>.  There is also a
            list:
                 quote:
                    text: >
                            The text of the quote, spanning multiple lines,
                            and it has embedded elements like <c p="value">this</c>
                            and <b>this</b>
                    author: The Author of this quote
            Text continues here.
</code>```

Also, is indentation not needed in some places?

答:
The YAML website describes YAML in the following terms:

```<code>YAML: YAML Ain't Markup Language

What It Is: YAML is a human friendly data serialization
  standard for all programming languages.
</code>```

You probably don't want YAML for this. YAML is meant to be used to save data out to files for future retrieval, basically as a form of serialization. The major benefit it has over XML in this regard is the fact that he lacks the clutter of XML's angle brackets and end tags. It's easy to read and edit for humans. XML, on the other hand, is already designed to work with an HTML-like syntax. XML's major purpose is as a markup language.

You could look at it this way:

Use YAML when you want to save text or objects to a file.

Use XML when you want to provide markup for
documents

Body:
I'm studying YAML as a replacement for XML, but I'm experiencing difficulties when dealing with elements containing free-flowing text with embedded elements.  For instance, the following XML document:

```<code>    <text>
    This is an example text, spanning multiple lines, and it has embedded elements
    like <a p="value">this</a> and <b>this</b>.  There is also a list:
         <quote>
            <text>The text of the quote, spanning multiple lines, and it has
            embedded elements like <c p="value">this</c> and <b>this</b></text>
            <author>The Author of this quote</author>
        </quote>
    Text continues here.
    </text>
</code>```

I don't know how to convert the embedded elements in YAML.  My understanding is that the above XML document segment translates to something like this (except for the embedded elements):

```<code>    text: >
            This is an example text, spanning multiple lines, and it has embedded
            elements like <a p="value">this</a> and <b>this</b>.  There is also a
            list:
                 quote:
                    text: >
                            The text of the quote, spanning multiple lines,
                            and it has embedded elements like <c p="value">this</c>
                            and <b>this</b>
                    author: The Author of this quote
            Text continues here.
</code>```

Also, is indentation not needed in some places?

Body:
The YAML website describes YAML in the following terms:

YAML: YAML Ain't Markup Language

What It Is: YAML is a human friendly data serialization
  standard for all programming languages.

You probably don't want YAML for this. YAML is meant to be used to save data out to files for future retrieval, basically as a form of serialization. The major benefit it has over XML in this regard is the fact that he lacks the clutter of XML's angle brackets and end tags. It's easy to read and edit for humans. XML, on the other hand, is already designed to work with an HTML-like syntax. XML's major purpose is as a markup language.

You could look at it this way:

Use YAML when you want to save text or objects to a file.

Use XML when you want to provide markup for
documents


问:
Cannot understand a certain point in Agile Manifesto Principles
I was reading Agile Manifesto Principles. Everything seems clear and reasonable except for one point:

Simplicity--the art of maximizing the amount of work not done--is
  essential.

I dont understand this. Does this mean that the work that wasn't done should be somehow exaggerated? If so, it doesn't really make sence.

答:
We used to call this "gold plating". The requirement for a hammer is that it can bash a nail into a piece of wood. It doesn't do the job any better for being a gold plated hammer.

Many times a developer would suggest using a new cool framework or adding features which though cool were not necessary. We would note this idea down, but for this version we won't do it. We will maximize the work not done. It is hard enough to deliver software on time, so don't deliver any more code than you need to. If it needs to be done, eventually it will get in the plan and be done at the appropriate time.


问:
What are the differences between Castle Monorail 3 over ASP.Net MVC?
I have been using Castle Monorail for some years now with great success, although I haven't bothered to update the version I'm using (2 or 3 year old). Now I'm making a decision on go to ASP.Net MVC 3 or update to the latest Castle version.

I have been looking documentation on the newest version of Castle projects (specially Monorail), but there is really little or no info around (I may be wrong).

Does someone knows what are the differences between Castle Monorail version 3 over ASP.Net MVC3?

Thanks!

答:
To paraphrase Twain the news of the death of the Castle project has been greatly exaggerated. Dynamic Proxy, for example, is used in countless .NET projects, to many to list. It is true that the Castle Project certainly does not always hold your hand with documentation and releases, but that has never been the case. If you were happy to use it in the past then the circumstances are little different.

As for the newest version of Monorail there are some things to consider. First of all it uses a completely different pattern to Monorail 2, that is to say "Composition over inheritance". It follows similar principles to FubuMVC, OpenRasta and NancyFX, unlike MR2 and Asp.net MVC which follow a base controller pattern. Secondly, MR3 is written in F#, not C#. And thirdly there is no upgrade path from MR2 to 3.

OwnerDisplayName: yorch


问:
Best practice on if/return
I want to know what is considered better way of returning when I have if statement.

Example 1:

```<code>public bool MyFunction()
{
   // Get some string for this example
   string myString = GetString();

   if (myString == null)
   {
      return false;
   }
   else
   {
      myString = "Name " + myString;
      // Do something more here...
      return true;
   }
}
</code>```

Example 2:

```<code>public bool MyFunction()
{
   // Get some string for this example
   string myString = GetString();

   if (myString == null)
   {
      return false;
   }

   myString = "Name " + myString;
   // Do something more here...
   return true;
}
</code>```

As you can see in both examples function will return true/false but is it a good idea to put else statement like in first example or it is better to not put it?

答:
This should be a matter of which sounds better.

```<code>If condition
  do something
else
  do somethingelse
</code>```

expresses itself better then

```<code>if condition
  do something
do somethingelse
</code>```

for small methods it wont be much of a difference, but for larger compound methods it can make it harder to understand as it wont be properly seperate

Title: Best practice on if/return

Body:
This should be a matter of which sounds better.

If condition
  do something
else
  do somethingelse

expresses itself better then

if condition
  do something
do somethingelse

for small methods it wont be much of a difference, but for larger compound methods it can make it harder to understand as it wont be properly seperate


答: Doing test driven development from the start on a customer delivery to see how it would affect the code quality, and only running from within the JUnit launcher in Eclipse.  It resulted in a better product.</p>


答: Example 2 is known as guard block. It is better suited to return/throw exception early if something went wrong (wrong parameter or invalid state). In normal logic flow it is better to use Example 1</p>

Title: Best practice on if/return

Body:
I want to know what is considered better way of returning when I have if statement.

Example 1:

```<code>public bool MyFunction()
{
   // Get some string for this example
   string myString = GetString();

   if (myString == null)
   {
      return false;
   }
   else
   {
      myString = "Name " + myString;
      // Do something more here...
      return true;
   }
}
</code>```

Example 2:

```<code>public bool MyFunction()
{
   // Get some string for this example
   string myString = GetString();

   if (myString == null)
   {
      return false;
   }

   myString = "Name " + myString;
   // Do something more here...
   return true;
}
</code>```

As you can see in both examples function will return true/false but is it a good idea to put else statement like in first example or it is better to not put it?


答: personally, I prefer the second method. I feel as though it's shorter, has less indentation, and is easier to read. </p>

Title: Best practice on if/return


答:
My personal practice is the following:

I don't like functions with several exit points, I found it hard to maintain and follow, code modifications sometimes break the internal logic because it is inherently a bit sloppy. When it is a complex calculation, I create a return value at the start and return it at the end. This forces me to carefully follow each if-else, switch, etc paths, set the value correctly at the proper locations. I also spend a bit of time on deciding whether to set a default return value, or leave it uninitialized at the start. This method also helps when the logic or the return value type or meaning changes.

For example:

```<code>public bool myFunction()
{
   // First parameter loading
   String myString = getString();

   // Location of "quick exits", see the second example
   // ...

   // declaration of external resources that MUST be released whatever happens
   // ...

   // the return variable (should think about giving it a default value or not)
   // if you have no default value, declare it final! You will get compiler
   // error when you try to set it multiple times or leave uninitialized!
   bool didSomething = false;

   try {
     if (myString != null)
     {
       myString = "Name " + myString;
       // Do something more here...

       didSomething = true;
     } else {
       // get other parameters and data
       if ( other conditions apply ) {
         // do something else
         didSomething = true;
       }
     }

     // Edit: previously forgot the most important advantage of this version
     // *** HOUSEKEEPING!!! ***

   } finally {

     // this is the common place to release all resources, reset all state variables

     // Yes, if you use try-finally, you will get here from any internal returns too.
     // As I said, it is only my taste that I like to have one, straightforward path
     // leading here, and this works even if you don't use the try-finally version.

   }

   return didSomething;
}
</code>```

The only one exception: "quick exit" at the start (or in rare cases, inside the process). If the real calculation logic can't handle a certain combination of input parameters and internal states, or has an easy solution without running the algorithm, it does not help to have all the code encapsulated in (sometimes deep) if blocks. This is an "exceptional state", not part of the core logic, so I must get out of the calculation as soon as I have detected. In this case there is no else branch, in normal conditions the execution simply goes on. (Of course, "exceptional state" is better expressed by throwing an exception, but sometimes it is an overkill.)

For example:

```<code>public bool myFunction()
{
   String myString = getString();

   if (null == myString)
   {
     // there is nothing to do if myString is null
     return false;
   }

   myString = "Name " + myString;
   // Do something more here...

   // not using return value variable now, because the operation is straightforward.
   // if the operation is complex, use the variable as the previous example.

   return true;
}
</code>```

The "one exit" rule also helps when the calculation requires external resources that you have to release, or states that you have to reset before leaving the function; sometimes they are added later during development. With multiple exits inside the algorithm, it is much harder to extend all branches properly. (And if exceptions may occur, the release/reset should be put in a finally block as well, to avoid side effects in rare exceptional cases...).

Your case seems to fall into the "quick exit before real work" category, and I would write it like your Example 2 version.

Title: Best practice on if/return

Body:
My personal practice is the following:

I don't like functions with several exit points, I found it hard to maintain and follow, code modifications sometimes break the internal logic because it is inherently a bit sloppy. When it is a complex calculation, I create a return value at the start and return it at the end. This forces me to carefully follow each if-else, switch, etc paths, set the value correctly at the proper locations. I also spend a bit of time on deciding whether to set a default return value, or leave it uninitialized at the start. This method also helps when the logic or the return value type or meaning changes.

For example:

public bool myFunction()
{
   // First parameter loading
   String myString = getString();

   // Location of "quick exits", see the second example
   // ...

   // declaration of external resources that MUST be released whatever happens
   // ...

   // the return variable (should think about giving it a default value or not)
   // if you have no default value, declare it final! You will get compiler
   // error when you try to set it multiple times or leave uninitialized!
   bool didSomething = false;

   try {
     if (myString != null)
     {
       myString = "Name " + myString;
       // Do something more here...

       didSomething = true;
     } else {
       // get other parameters and data
       if ( other conditions apply ) {
         // do something else
         didSomething = true;
       }
     }

     // Edit: previously forgot the most important advantage of this version
     // *** HOUSEKEEPING!!! ***

   } finally {

     // this is the common place to release all resources, reset all state variables

     // Yes, if you use try-finally, you will get here from any internal returns too.
     // As I said, it is only my taste that I like to have one, straightforward path
     // leading here, and this works even if you don't use the try-finally version.

   }

   return didSomething;
}

The only one exception: "quick exit" at the start (or in rare cases, inside the process). If the real calculation logic can't handle a certain combination of input parameters and internal states, or has an easy solution without running the algorithm, it does not help to have all the code encapsulated in (sometimes deep) if blocks. This is an "exceptional state", not part of the core logic, so I must get out of the calculation as soon as I have detected. In this case there is no else branch, in normal conditions the execution simply goes on. (Of course, "exceptional state" is better expressed by throwing an exception, but sometimes it is an overkill.)

For example:

public bool myFunction()
{
   String myString = getString();

   if (null == myString)
   {
     // there is nothing to do if myString is null
     return false;
   }

   myString = "Name " + myString;
   // Do something more here...

   // not using return value variable now, because the operation is straightforward.
   // if the operation is complex, use the variable as the previous example.

   return true;
}

The "one exit" rule also helps when the calculation requires external resources that you have to release, or states that you have to reset before leaving the function; sometimes they are added later during development. With multiple exits inside the algorithm, it is much harder to extend all branches properly. (And if exceptions may occur, the release/reset should be put in a finally block as well, to avoid side effects in rare exceptional cases...).

Your case seems to fall into the "quick exit before real work" category, and I would write it like your Example 2 version.


问:
iOS: Versioned static frameworks vs Git Submodules and included code
For the last couple of years I've been building static frameworks of common APIs for my iOS projects. I can build a universal binary containing all the architectures (i386, armv6, armv7) and wrap it up in a .framework directory structure. I then stored this in a directory based on the version of the framework. For example ..../myAPI/v0.1.0/myAPI.framework

Once I have this framework I can then easily add it to a project and if I want to advance the version, merely change the framework search paths to the later version.

This works, but the approach is very similar to what I would use in the Java world.

Recently I've been reading about using Git submodules and static framework sub projects in XCode 4.

Im wondering if my currently approach is something that I should consider retiring and what the pros/cons are of the new approach.

I'm weary of just including code because I've already had issues in a work project which had (effectively) multiple versions of a third party API.

Any opinions?

答:
Back again. Been playing with some projects to try and get my head around these questions.

It's nice that I can have embedded projects within XCode and Git. However they seem to increase the chances of issues and mistakes. Working this way also means that submodules are scattered all over the place, duplicated many time. This I think increases the chances of code clashes.

There seems to be a lot more complexity in working this way over the way I was working and I'm not sure if I am really gaining much from it.


答:
I prefer to employ guard blocks where ever I can for two reasons:

They allow a quick exit given some specific condition.

The remove the necessity for complex and un-necessary if statements later in the code.

Generally speaking I prefer to see methods where the core functionality of the method is clear and minimal. Guard blocks help to visually make this happen.

Title: Best practice on if/return


答:
I find example 1 irritating, because the missing return statement at the end of a value-returning function immediately triggers the "Wait, there's something wrong"-flag. So in cases like this, I would go with example 2.

However, usually there is more involved, depending on the purpose of the function, e.g. error handling, logging, etc. So I'm with Lorand Kedves' answer on this, and usually have one exit point at the end, even at the cost of an additional flag variable. It makes maintenance and later extensions easier in most cases.

Title: Best practice on if/return


答:
I like the "Fall Through" approach:

```<code>public bool MyFunction()
{
   string myString = GetString();

   if (myString != null)
   {
     myString = "Name " + myString;
     return true;
    }
    return false;
}
</code>```

The action has a specific condition, anything else is just the default "fall through" return.

Title: Best practice on if/return

Body:
I like the "Fall Through" approach:

public bool MyFunction()
{
   string myString = GetString();

   if (myString != null)
   {
     myString = "Name " + myString;
     return true;
    }
    return false;
}

The action has a specific condition, anything else is just the default "fall through" return.


问:
Css design skills
I have seen this article: CSS3 Loading elements at HTML5 and CSS3 Tutorials pages.

How did someone made this calculations? what angle, how much space, how much rotation to give?

If I do it with hand, starting number one, I fear it takes too long as a process to complete.
Is there some tool, or some trick that do this or is it based on some technique that I am unaware somehow?

[EDIT] I am trying to tweak the width and height of this CSS, in order to make it smaller, and is broken. It seems to be calculated as is and you can't touch it.

答:
Angle / rotation: 360 / # of elements = angle.

So, if you want an 8-sided (as is used by CSS code), use 45 degree angle increments.

The time calculations are just (element number) * delay, with delay being 0.13.

Hence, the animation duration is 1.04 (0.13 * 8) and each element's delay is 0.13 higher than the previous one.

Title: Css design skills


答:
My personal style is to use the single if for guard blocks, and the if/else in the actual method processing code.

In this case, you're using the myString == null as a guard condition, so I would tend to use the single if pattern.

Consider code that's a little more complicated:

Example 1:

```<code>public bool MyFunction(myString: string){

    //guard block
    if (myString == null){
        return false;
    }
    else{
        //processing block
        myString = escapedString(myString);

        if (myString == "foo"){
            //some processing here
            return false;
        }
        else{
            myString = "Name " + myString;
            //other stuff
            return true;
        }
    }
}
</code>```

Example 2:

```<code>public bool MyFunction(myString: string){

    //guard block
    if (myString == null){
        return false;
    }

    //processing block
    myString = escapedString(myString);

    if (myString == "foo"){
        //some processing here
        return false;
    }
    else{
        myString = "Name " + myString;
        //other stuff
        return true;
    }
}
</code>```

In Example 1, both the guard and the rest of the method are in the if/else form. Compare that to Example 2, where the guard block is in the single if form, while the rest of the method uses the if/else form. Personally, I find example 2 easier to understand, while example 1 looks messy and over-indented.

Note that this is a contrived example and that you could use else if statements to clean it up, but I'm aiming to show the difference between guard blocks and the actual function processing code.

A decent compiler should generate the same output for both of them anyway. The only reason to use one or the other is personal preference or to conform to the style of the existing code.

Title: Best practice on if/return

Body:
My personal style is to use the single if for guard blocks, and the if/else in the actual method processing code.

In this case, you're using the myString == null as a guard condition, so I would tend to use the single if pattern.

Consider code that's a little more complicated:

Example 1:

public bool MyFunction(myString: string){

    //guard block
    if (myString == null){
        return false;
    }
    else{
        //processing block
        myString = escapedString(myString);

        if (myString == "foo"){
            //some processing here
            return false;
        }
        else{
            myString = "Name " + myString;
            //other stuff
            return true;
        }
    }
}

Example 2:

public bool MyFunction(myString: string){

    //guard block
    if (myString == null){
        return false;
    }

    //processing block
    myString = escapedString(myString);

    if (myString == "foo"){
        //some processing here
        return false;
    }
    else{
        myString = "Name " + myString;
        //other stuff
        return true;
    }
}

In Example 1, both the guard and the rest of the method are in the if/else form. Compare that to Example 2, where the guard block is in the single if form, while the rest of the method uses the if/else form. Personally, I find example 2 easier to understand, while example 1 looks messy and over-indented.

Note that this is a contrived example and that you could use else if statements to clean it up, but I'm aiming to show the difference between guard blocks and the actual function processing code.

A decent compiler should generate the same output for both of them anyway. The only reason to use one or the other is personal preference or to conform to the style of the existing code.


问:
FizzBuzz - really?
When it comes to "interview test" questions, the subject of FizzBuzz often comes up. There is also a Coding Horror post about it.

Now, if you bother reading sites such as this, you are probably less likely to be in the demographic of programmers who would find FizzBuzz anything but trivial.

But is it really true that 99% of programmers will struggle with it?

Really?

What is the evidence to back this up?

Some real-life examples would be very helpful in answering this question.

答:
Yes really. Probably not 99% but still pretty high. I used to interview computer science students for internships and full time hires. I'd interview about 25 students at a college.
We were told not to ask the same questions, because the students talked. I quickly learned that it didn't matter, because I would only get 3 or 4 students out of the 25 who could answer my first question. "Write strcmp"

I asked them to write a function to compare two strings. Maybe to use the function to sort words for a dictionary. You would be amazed at the number of students who didn't understand how to compare two words, let alone know how to write the function. And some of these students claimed they got all A's in CSc.

The thing is programming is VERY DIFFICULT. A lot of people like to think they know how to program, but they don't.

Title: FizzBuzz - really?