答:
There are quite a few such studies.  Google is your FRIEND.

Halstead's metrics fell out of favor when it was demonstrated that all of them were strongly correlated with raw SLOC (source lines of code).  At that point, it becomes easier to measure SLOC and be done with it.

Here's a result from Google Books.

Title: Is there any work into the application of the Halstead complexity measures to determine software quality?

Body:
In 1977, Maurice Howard Halstead introduced his complexity measures for software systems, which included measurements of the program vocabulary, program length, volume, difficulty, effort, and an estimated number of bugs in a module. According to Wikipedia, difficulty relates to the difficulty of understanding the program when reading or writing it and effort can be translated into the time it takes to code an application where Time = (Effort / 18) seconds.

A measurement is useless unless the data and calculations relate to some aspect of software development. However, I haven't found any work which states that a difficulty of a certain value or higher tends to a statistically significant increase in defects or a relationship between difficulty and time to read code (a difficulty of N yields an average of M hours spent understanding the code base) or any analysis of being able to compute Time after the fact being useful in determining quality (especially since time to write should have been recorded as a measurement already). I'm especially interested in Halstead's bug estimation (which is not mentioned on Wikipedia) - the number of bugs in an application can be estimated by Volume/3000 or Effort^(2/3)/3000.

I'm looking for two things:

Has anyone used Halstead's software complexity measures in a real-world application to assess software quality? If so, how did you apply them and did they turn out to be a useful, valid, and/or reliable measurement?

Is there any academic research in the form of surveys, analyses, or case studies that discuss the validity (or invalidity) of Halstead complexity measures when applied to software quality?

Is there any academic research in the form of surveys, analyses, or case studies that demonstrate the use of Source Lines of Code (SLOC) to compute something similar to the Halstead metrics of Volume, Difficulty, Effort, Time, and Bugs? I would suspect that Volume might just correspond to a SLOC count and Difficulty might correspond to cyclomatic complexity (and possibly other measures). I'm also well aware that measuring effort, productivity, or time in SLOC is potentially misleading.


问:
What's your favourite quote about programming?
What's your favourite quote about programming?

One quote per answer, and please check for duplicates before posting!

答:
I'll call him Mel, because that was his name.

From The story of Mel

ContentLicense: CC BY-SA 3.0

LastEditorDisplayName: Roger Pate

ContentLicense: CC BY-SA 2.5


问:
To branch or not to branch?
Till recently my development workflow was the following:

Get the feature from product owner

Make a branch (if feature is more than 1 day)

Implement it in a branch

Merge changes from main branch to my branch (to reduce conflicts during backward merging)

Merge my branch back to main branch

Sometimes there were problems with merging, but in general I liked it.

But recently I see more and more followers of idea to not make branches as it makes more difficult to practice continuous integration, continuous delivery, etc. And it sounds especially funny from people with distributed VCS background who were talking so much about great merging implementations of Git, Mercurial, etc.

So the question is should we use branches nowadays?

答:
Yes, you should use branches to isolate any (at least medium) development effort. See "When should you branch?".

The issue is more to use fast-forward merges (which include a branch history within another one), provided you squash first all the "intermediate checkpoint commits" (which can be an issue in case of rollback or git bisect).

See "Understanding Git workflow", in order to distinguish private branches (not meant to be pushed) from public branches, which will be completed by ff merges (fast-forward merges) provided that you make the necessary cleanup within the branch you are merging.

See also "Why does git use fast-forward merging by default?".

Title: To branch or not to branch?

OwnerDisplayName: VonC


问:
When should I use a 2-property class over a pre-built structure like a KeyValuePair?
When should you put Key/Value type of data in it's own class instead of using a pre-built generic structure, such as a KeyValuePair or a Tuple?

For example, most ComboBoxes I create contain a DisplayName and a Value. This is the kind of data I am trying to decide when to put in a new class, and when to just use a KeyValuePair.

I am currently working on something that uses iCalendar, and the selected user's data ultimately gets combined into a key1=value1;key2=value2; type of string. I started out by putting the data in a KeyValuePair<string,string>, but now I am wondering if that should be it's own class instead.

Overall, I am interested in finding out what guidelines are used when deciding to use an existing structure/class like a KeyValuePair over a 2-property object, and in what kind of situations you would use one over another.

答:
I'd generally use an object rather than a KeyValuePair or Tuple in most cases. First, when you come in 6 months later to make changes, it is alot easier to figure out what your intent was earlier rather than wondering what Tuple t is and why it has those funny values. Second, as things grow and change you can easily give your simple data transfer objects behavior as required. Need to have two name formats? Easy, just add appropriate ToString() overloads. Need it to implement some interface? No problem. Finally, there really is nearly zero overhead to creating a simple object, especially with automatic properties and code completion.

Bonus Protip: if you want to keep these objects from polluting your namespace, making private classes inside of classes is a great way to keep things under wraps and prevent strange dependencies.


问:
How do I decide whether to take a job I can't add to my portfolio?
I am a programmer, but since I've barely been in the professional market my portfolio is rather bare right now. Still, I started to try and get my website up and running to help a little bit, but what I really need right now is to be able to expand my portfolio.

I have a guy who wants me to do a lot of work for him, and I'm willing to do it for a while at least until I can get better jobs. The real problem, though, is that he does not want me to tell anyone that I have been doing work for him. Naturally, since I'm both trying to earn money and expand my portfolio, this poses a problem.

Part of the reason for doing an app was to prove I can develop one, but if I can't tell anyone I wrote it, then developing the app seems pointless; I may be better off creating my own app and eating the loss in profit because I can get more work out of it, but of course, at the same time, I'm in desperate need of cash. I do have jobs lined up elsewhere, but I'll likely get paid faster through doing this specific job.

What factors should I be looking at when making a decision on whether or not I should take a job for money that I can't talk about?

答:
Sounds to me like you need to add the job to your resume in vague, general terms with Redacted in the space where you would normally say who you were working for, then when you're asked about it at an interview, you can be all mysterious and say that you are bound by contract not to say who you were working for.

It would certainly make you stand out, but whether that is stand out in a good way or not will depend on who you are applying to. *8')


问:
AGPL - what you can do and what you can't
AGPL is a fairly new license that was meant to go GPL-over-networks. However, not being a lawyer, and actually not having read the whole license, I can't understand what exactly you can do freely and what not with AGPL.

My uncertainty is fed by this post about MongoDB (which is AGPL) and even more by the comments below.

If we follow the comments it turns out that you can use AGPL libraries with your closed-source, commercial server-side software, as long as you don't modify the library. Is that the case? Or you have to distribute your entire application when you use an AGPL licensed library?

The case with MongoDB is that it uses Apache license for the client code, which poses another question. What happens if you use AGPL software, but deploy it as a different application that your closed-source commercial one? For example, take iText - it is an AGPL library:

if you use it and modify it, do you have to open-source your entire application or you have to redistribute only the changes in iText?

if you use it and don't modify it, do you have to open-source your entire application?

If you wrap iText in another application that you start as a separate process, but use it from your main application, should you open-source everything, or just the wrapper application? (The wrapper application will be HTTP-based API that will take pdf files and will return the results of using iText as JSON). Can this be used to circumvent the AGPL license?

Note: The question is about AGPLv3

答:
AGPL is the same as GPL; therefore if your app is using AGPL code it has to be AGPL licensed.

What AGPL does on top of GPL is the redefinition of user. For GPL programs running on your server, you are the user, for AGPL, the real users of the app are the users of your website or service. Therefore you are distributing the app if someone other than you is using it. And that of course implies all the standard GPL requirements.

As for Mongo, I'm assuming that apps using it don't use it's code, only some API, which isn't AGPL licensed.


答: Chapter six of Clean Code has a good description of when to use a data structure versus a class.  In a nutshell, you use a data structure when you mostly anticipate adding new functions to operate on that data.  You use a class when you mostly anticipate adding new data types to be operated on by existing functions.  Your ComboBox is an example of the latter.  You have one set of functions (the ComboBox implementation) operating on many different data types (different kinds of data for different widgets).</p>

Title: When should I use a 2-property class over a pre-built structure like a KeyValuePair?

Body:
When should you put Key/Value type of data in it's own class instead of using a pre-built generic structure, such as a KeyValuePair or a Tuple?

For example, most ComboBoxes I create contain a DisplayName and a Value. This is the kind of data I am trying to decide when to put in a new class, and when to just use a KeyValuePair.

I am currently working on something that uses iCalendar, and the selected user's data ultimately gets combined into a key1=value1;key2=value2; type of string. I started out by putting the data in a KeyValuePair<string,string>, but now I am wondering if that should be it's own class instead.

Overall, I am interested in finding out what guidelines are used when deciding to use an existing structure/class like a KeyValuePair over a 2-property object, and in what kind of situations you would use one over another.


问:
PHP vs C# performance
I have a application that is part console application written in C# and part PHP web application.

The console application connects to multiple serial devices and reads data pertaining to moisture and temperature in a Grain Dryer. [The application] then stores the information in a MySQL database.

The PHP reads the MySQL database and displays the information to the user (simple).

I have also written a PHP script to email / sms the user if one of the temperatures of moistures reaches alarm levels (alarm levels are read off the device and stored in the MySQL database).

Currently, I post to the PHP page with each "update" from the device (10 seconds) and check each value against it's limits. If an alarm is required I send it off and update the database indicating an alarm has been sent.

This looks like (pseudo code)

```<code>IF moisture IS GREATER THAN moisture_high_critical_limit THEN
  IF moisture_high_critical_alarm_has_been_sent IS FALSE THEN
    SEND_ALARM();
    moisture_high_critical_alarm_has_been_sent = TRUE;
  END IF
ELSE IF moisture IS GREATER THAN moisture_high_warning_limit THEN
  IF moisture_high_warning_alarm_has_been_sent IS FALSE THEN
    SEND_ALARM();
    moisture_high_warning_alarm_has_been_sent = TRUE;
  END IF
ELSE IF moisture IS LESS THAN moisture_low_critical_limit THEN
  IF moisture_low_critical_alarm_has_been_sent IS FALSE THEN
    SEND_ALARM();
    moisture_low_critical_alarm_has_been_sent = TRUE;
  END IF
ELSE IF moisture IS LESS THAN moisture_low_warning_limit THEN
  IF moisture_low_warning_alarm_has_been_sent IS FALSE THEN
    SEND_ALARM();
    moisture_low_warning_alarm_has_been_sent = TRUE;
  END IF
END IF
</code>```

The above IF statement is repeated for every temperature and moisture reading from the device, which can be quite a few.

Should this type of processing be happening in my Console application? Then if a Alarm notification is required post to the page only to send the email / SMS?

Processing this information in the console application will reduce my total number of handshakes with the MySQL Database. But if the MySQL Database is hosted locally will this have much impact?

I will eventually benchmark both (if it seems the doing the processing in the console application is in fact the right approach), however there is a lot of code to port over so I thought I'd come here and ask first.

答:
From your description it sounds like your app performs a lot of DB and other network traffic. That is supposed to take magnitudes more time than executing the above code a few million times, be it in PHP or C#.

I would suggest you profile your app first, to see where the real bottlenecks are your app spends the most time, then focus on these areas. Typically, optimizing the way you query/update the DB (e.g. minimizing the number of roundtrips to the DB by performing batch updates instead of series of singular updates whenever you can) saves you way more time than any local processor time optimization.

Title: PHP vs C# performance


答:
If you write your own class you have a clear place to put the documentation about what the two values are. Especially since two strings isn't a very clear definition.  However you could write something like</p>

```<code> public class MyPair : Tuple<string, string>
</code>```

Body:
If you write your own class you have a clear place to put the documentation about what the two values are. Especially since two strings isn't a very clear definition.  However you could write something like

 public class MyPair : Tuple<string, string>


答: I agree with @Péter Török regarding the optimization points, but in an effort to provide a small code optimization you might want to consider the Windows Workflow Foundation for C#. It was designed with just this kind of optimized flow control in mind. We're currently employing it to make determinations on data and execute data insertions, perform notifications, etc based on the results of a data analysis.</p>

Title: PHP vs C# performance

Body:
I have a application that is part console application written in C# and part PHP web application.

The console application connects to multiple serial devices and reads data pertaining to moisture and temperature in a Grain Dryer. [The application] then stores the information in a MySQL database.

The PHP reads the MySQL database and displays the information to the user (simple).

I have also written a PHP script to email / sms the user if one of the temperatures of moistures reaches alarm levels (alarm levels are read off the device and stored in the MySQL database).

Currently, I post to the PHP page with each "update" from the device (10 seconds) and check each value against it's limits. If an alarm is required I send it off and update the database indicating an alarm has been sent.

This looks like (pseudo code)

```<code>IF moisture IS GREATER THAN moisture_high_critical_limit THEN
  IF moisture_high_critical_alarm_has_been_sent IS FALSE THEN
    SEND_ALARM();
    moisture_high_critical_alarm_has_been_sent = TRUE;
  END IF
ELSE IF moisture IS GREATER THAN moisture_high_warning_limit THEN
  IF moisture_high_warning_alarm_has_been_sent IS FALSE THEN
    SEND_ALARM();
    moisture_high_warning_alarm_has_been_sent = TRUE;
  END IF
ELSE IF moisture IS LESS THAN moisture_low_critical_limit THEN
  IF moisture_low_critical_alarm_has_been_sent IS FALSE THEN
    SEND_ALARM();
    moisture_low_critical_alarm_has_been_sent = TRUE;
  END IF
ELSE IF moisture IS LESS THAN moisture_low_warning_limit THEN
  IF moisture_low_warning_alarm_has_been_sent IS FALSE THEN
    SEND_ALARM();
    moisture_low_warning_alarm_has_been_sent = TRUE;
  END IF
END IF
</code>```

The above IF statement is repeated for every temperature and moisture reading from the device, which can be quite a few.

Should this type of processing be happening in my Console application? Then if a Alarm notification is required post to the page only to send the email / SMS?

Processing this information in the console application will reduce my total number of handshakes with the MySQL Database. But if the MySQL Database is hosted locally will this have much impact?

I will eventually benchmark both (if it seems the doing the processing in the console application is in fact the right approach), however there is a lot of code to port over so I thought I'd come here and ask first.


答:
The rule for defining a new class is simple: It's summarized by "Occam's Razor".

http://c2.com/cgi/wiki?OccamsRazor

Do not introduce new classes without a good reason.  Or
use pre-built classes as much as possible.  Or invent as little as possible.  However you're comfortable writing less code.

You cannot use a pre-built class if you have to assign some unique responsibility to the object and that responsibility is not defined in the pre-built class.  Often this is a unique method.

A tuple or KeyValuePair is preferred.

Until.

You need some functionality that's not part of A tuple or KeyValuePair.  Then you have to define your own class.


问:
Arguments for or against using Try/Catch as logical operators
I just discovered some lovely code in our companies app that uses Try-Catch blocks as logical operators.

Meaning, "do some code, if that throws this error, do this code, but if that throws this error do this 3rd thing instead".

It uses "Finally" as the "else" statement it appears.

I know that this is wrong inherently, but before I go picking a fight I was hoping for some well thought out arguments.

And hey, if you have arguments FOR the use of Try-Catch in this manner, please do tell.

For any who are wondering, the language is C# and the code in question is about 30+ lines and is looking for specific exceptions, it is not handling ALL exceptions.

答:
This sounds like using exception handling to build goto logic on top of a language that doesn't have a goto command.

For the many reasons why goto logic is bad, you can refer to this question:
https://stackoverflow.com/questions/46586/goto-still-considered-harmful


问:
What is the best idea to put available OS (linux) and Web application to client?
After a year programming a web based business management system, I got my idea divided into two differents ways to do what I'm doing... I will try to explain in follow lines:

First I will describe my enviroment:

Webserver: apache, ngynx

Programming Language: PHP, Shell Script, Java Script, SQL

Database: Mysql

Operating System: Linux, UNIX (All Distros) (If manually configured works on windows)

Authentication Server: FreeRadius

First situation

I have my application running on this enviroment that I had just described before, as my application is a SaaS app, then I have my own server to run it all and customers pay to use it as a service accessed by webbrowser.

Second Situation

The same as before but with one big difference, everything (environment) is installed in the customer, then I need to cryptography all my codes (It includes PHP and Shell Scripts). I think this situation is most difficulty, but I would like to hear it from different points of view.

答:
Use SaaS:

You will update your product ASAP, users will always have last version

You will decide, which version of PHP and MySQL (etc) you will use

It's much more easy to users to pay per month / per day, than for whole product

"Cloud technologies" it's a future of IT world :)


答:
Considered simply shipping a virtual machine image with your favorite Linux and your application to the customer?

Then you can have it exactly as you want, and then let the Linux update mechanism handle your application too.

Title: What is the best idea to put available OS (linux) and Web application to client?

Body:
After a year programming a web based business management system, I got my idea divided into two differents ways to do what I'm doing... I will try to explain in follow lines:

First I will describe my enviroment:

Webserver: apache, ngynx

Programming Language: PHP, Shell Script, Java Script, SQL

Database: Mysql

Operating System: Linux, UNIX (All Distros) (If manually configured works on windows)

Authentication Server: FreeRadius

First situation

I have my application running on this enviroment that I had just described before, as my application is a SaaS app, then I have my own server to run it all and customers pay to use it as a service accessed by webbrowser.

Second Situation

The same as before but with one big difference, everything (environment) is installed in the customer, then I need to cryptography all my codes (It includes PHP and Shell Scripts). I think this situation is most difficulty, but I would like to hear it from different points of view.


问:
Workflow for a plugin assignment
I'm starting a new project in PHP, a plugin for a website that grabs additional data from it through cURL, getContents etc and re-tabulates it in excel. It's a local project, basic script like with a very limited UI. Iv'e been using Codeigniter and it's a great framework for websites, and even the Twitter application I'm using it for but I don't think I need MVC (necessarily) for this small project but I also don't want to go bare. What would your typical workflow be for this kind of weekend assignment where your creating a local do-something script or like in my case adding functionality to a website? Is there something in between a light weight MVC framework and a blank page?</p>

答:
If you want to build MVC-structure, you can do it even without framework. It's easy.

If you want to write little script isn't mandatory to build MVC. Just keep it SOLID, and it will live long and happy life :)

Title: Workflow for a plugin assignment


问:
Are there advantages to using a DVCS for a solo developer?
Right now, I use visual svn on my server, and have ankhsvn/tortoise on my personal machine. It works fine enough, and I don't have to change, but if I can see some benefits of using a DVCS, then I might give it a go.

However, if there's no point or difference using it without other people, then I won't bother.

So again, I ask, are there any benefits to using a DVCS when you're the only developer?

答:
Yes! I think the biggest benefit is the better branching + merging support offered by many DVCSes. Branching and merging is kind of a pain in the ass in SVN; it's annoying enough that it's not worth the time to create small, short-lived branches for quick feature additions, bug fixes, or experimentation, but merging is also annoying enough that it's a pain to create long-lived branches as well. On the other hand, branching and merging is a breeze in Git, so much so that I create a (local) branch for nearly every bug fix or feature I work on.

I think the tools offered by Git for visualizing repos, grepping logs, etc., are a lot better than in SVN, too (although that's more a Git thing than specific to a DVCS).

A DVCS also doesn't require a central server; when using SVN as a developer, you have to create a local repo to push into, which isn't a requirement with Git, since every repo contains the full history. As a corollary, archiving a repo is just a matter of zipping up your project -- there's no "central database" to back up.

I started using Git nearly four years ago, after using SVN for a while, and I haven't looked back.


问:
Recursion without factorial, Fibonacci numbers etc
Almost every article I can find about recursion includes the examples of factorial or Fibonacci Numbers, which are:

Math

Useless in real life

Are there some interesting non-math code examples to teach recursion?

I'm thinking divide-and-conquer algorithms but they usually involve complex data structures.

答:
In functional programming languages, when no higher-order functions are available, recursion is used instead of imperative loops in order to avoid mutable state.

F# is an impure functional language which allows both styles so I will compare both here. The following sum all the numbers in a list.

Imperative Loop with Mutable Variable

```<code>let xlist = [1;2;3;4;5;6;7;8;9;10]
let mutable sum = 0
for x in xlist do
    sum <- sum + x
</code>```

Recursive Loop with No Mutable State

```<code>let xlist = [1;2;3;4;5;6;7;8;9;10]
let rec loop sum xlist =
    match xlist with
    | [] -> sum
    | x::xlist -> loop (sum + x) xlist
let sum = loop 0 xlist
</code>```

Note that this kind of aggregation is captured in the higher order function List.fold and could be written as List.fold (+) 0 xlist or indeed even more simply with the convenience function List.sum as just List.sum xlist.

Body:
In functional programming languages, when no higher-order functions are available, recursion is used instead of imperative loops in order to avoid mutable state.

F# is an impure functional language which allows both styles so I will compare both here. The following sum all the numbers in a list.

Imperative Loop with Mutable Variable

let xlist = [1;2;3;4;5;6;7;8;9;10]
let mutable sum = 0
for x in xlist do
    sum <- sum + x

Recursive Loop with No Mutable State

let xlist = [1;2;3;4;5;6;7;8;9;10]
let rec loop sum xlist =
    match xlist with
    | [] -> sum
    | x::xlist -> loop (sum + x) xlist
let sum = loop 0 xlist

Note that this kind of aggregation is captured in the higher order function List.fold and could be written as List.fold (+) 0 xlist or indeed even more simply with the convenience function List.sum as just List.sum xlist.


问:
How long should a sprint planning meeting last?
In your experience, how long should a Sprint Planning meeting (Scrum) last? 8 hours? Or should it be shorter (succinct) and further discussions should be planned as part of the sprint? Our Sprints are 10 days long.</p>

答:
According to the Scrum Guide:

The Sprint Planning Meeting is time-boxed to eight hours for a one-month Sprint. For shorter Sprints, the event is proportionately shorter. For example, two-week Sprints have four-hour Sprint Planning Meetings.

That generally works for me.


问:
How does Python work?
This question may seems a little bit silly, but what the heck.

I started to learn Python. I know basic syntax, etc.

When I work with HTML, PHP, etc., I simply write code, put it inside .html or .php file and double click this file. Then my code runs. I can work with databases and other stuff - it's just simple. But how does Python work? I'm working inside Eclipse or Python command line and I can run this code, but what if I want make website with Python for example?

I don't think it's like I put .py file on my server, so what I need to do? I understand I need to install Python on my webserver through some server command line (I've never used it, but I will find some tutorials day I will need it) but what's next? How can I combine my Python knowledge with HTML, CSS, PHP, etc.?

Python may also be used to create desktop apps, what then? Can I export .exe file with Python code or what?

Any links with content describing my concerns are welcome!

答:
How can I combine my Python knowledge with html, css, php etc?

Use a web framework that supports Python, such as Django.

Python may also be used to create desktop apps, what then? Can I
  export .exe file with Python code or what?

Python is typically executed by an interpreter, so it's easy to use interactively and you can see results of your changes almost immediately. A Python program can also be packaged up into a stand-alone executable; more on how to do that here.

Title: How does Python work?


答:
The AGPL is based on the GPL, not the LGPL. It does not contain any linking exceptions, and any work using AGPL code (linked or otherwise, modified or not) must also be AGPL licensed and distributed.

Using separate processes can circumvent the (A)GPL, but this is murky ground. If your end application depends on the external process, such that it wouldn't function properly without it, then it would be considered a derived work of the AGPL software.

In most cases where people use separate GPL applications in closed source programs, they provide the GPL work as an optional extension, or an alternative back-end to some other piece of code etc.

The (A)GPL work cannot be distributed alongside the final application even as a separate app (eg, putting them into the same archive or repository), although it's fine to provide instructions on where to find the GPL work and how to use it with your app.

Title: AGPL - what you can do and what you can't

Body:
AGPL is a fairly new license that was meant to go GPL-over-networks. However, not being a lawyer, and actually not having read the whole license, I can't understand what exactly you can do freely and what not with AGPL.

My uncertainty is fed by this post about MongoDB (which is AGPL) and even more by the comments below.

If we follow the comments it turns out that you can use AGPL libraries with your closed-source, commercial server-side software, as long as you don't modify the library. Is that the case? Or you have to distribute your entire application when you use an AGPL licensed library?

The case with MongoDB is that it uses Apache license for the client code, which poses another question. What happens if you use AGPL software, but deploy it as a different application that your closed-source commercial one? For example, take iText - it is an AGPL library:

if you use it and modify it, do you have to open-source your entire application or you have to redistribute only the changes in iText?

if you use it and don't modify it, do you have to open-source your entire application?

If you wrap iText in another application that you start as a separate process, but use it from your main application, should you open-source everything, or just the wrapper application? (The wrapper application will be HTTP-based API that will take pdf files and will return the results of using iText as JSON). Can this be used to circumvent the AGPL license?

Note: The question is about AGPLv3


答:
If two teams work on their own branch, they won't see the changes of the other team, even if both integrate the master branch. That would mean their development branches will drift apart and if one of the teams would merge with master, the other team has to rebase a lot of changes.

So even if you have branches for features I would urge you to make 'backports' of all refactorings to the master branch and keep the branch only for new features.

Backport refactorings

I think sometimes it might be more easy to use feature switches to disable new, untested features that should not go into production yet. That way all other teams will see the changes and no big bang merge has to happen.

Use feature switches

Title: To branch or not to branch?

Body:
Till recently my development workflow was the following:

Get the feature from product owner

Make a branch (if feature is more than 1 day)

Implement it in a branch

Merge changes from main branch to my branch (to reduce conflicts during backward merging)

Merge my branch back to main branch

Sometimes there were problems with merging, but in general I liked it.

But recently I see more and more followers of idea to not make branches as it makes more difficult to practice continuous integration, continuous delivery, etc. And it sounds especially funny from people with distributed VCS background who were talking so much about great merging implementations of Git, Mercurial, etc.

So the question is should we use branches nowadays?


问:
Comparing Visual Foxpro with .NET
I used Foxpro 2.6 a decade ago. In my present company, few new  projects are being developed in Visual Foxpro 9.0 and few projects are on .NET platform. From time-to-time I notice how Visual Foxpro is more powerful as compared to .NET when comparing dependency issues.

Here are some of the advantages of VFP I noticed:

There is no hard and fast rule to use another full-fledged RDBMS. Even though the latest version of Visual Foxpro can be connected to SQL Server, but I have seen very large projects still, happily, using the old DBF. With .NET you have to connect to another RDBMS and it just adds to your Setup dependency.

Foxpro has built-in rich reporting capability since the time of DOS era, whereas .NET developers have to depend on Crystal Reports, SSRS or other third-party variants.

Visual Foxpro 9.0 has .NET capabilities as well. However, it is not dependent on .NET and therefore your final executable doesn't need .NET framework installed, which is again a dependency.

I have seen very large databases of Foxpro in few major government organizations, successfully running from a long time. These organizations don't feel a need to shift to SQL Server, not because of migration risks, but because they are happy with VFP.

I want to step into VFP world but I read somewhere that Microsoft is stopping further developments of VFP and also stopping support to VFP 9.0 from 2015 onwards.

What you guys suggest?

答:
If you are living in a world where an app tightly coupled to the storage and only speaking relational gets the job done, then no, there really isn't much advantage of moving on from VFP.

That world is getting smaller and smaller. And the last version of VFP was released in 2007 and it is pretty clear that the platform has been given the old heave-ho by Microsoft. I definitely would not develop anything new in VFP.

On the other hand, there are some FORTRAN and COBOL guys who work 10 hours a week and drive porsches.

Title: Comparing Visual Foxpro with .NET


答:
When I work with HTML, PHP, etc., I simply write code, put it inside .html or .php file and double click this file. Then my code runs.

But how does Python work?

Exactly the same way.

Double-click a .py file and your code runs.

I'm working inside Eclipse or Python command line and I can run this code, but what if I want make website with Python for example?

You usually use Apache to host a web site.  You usually use mod_wsgi to run Python inside Apache.  This is exactly like using  mod_php to run PHP inside Apache.

Exactly the same.

I don't think it's like I put .py file on my server,

False.  You do put .py files on your server.  How else could it possibly work?

so what I need to do? I understand I need to install Python on my webserver through some server command line (I've never used it, but I will find some tutorials day I will need it) but what's next?

You need mod_php to run PHP.  You need mod_wsgi to run Python.

So if I made some website with Python, then my user will see my index.py file when he comes to my server?

You could do that.  It would be fairly silly, however.

Usually, you set up mod_wsgi so that it executes your .py file, and your .py file creates the HTML page.

This parallels the way mod_php executes the .php file to create an HTML page.

Or can I use Python code inside html like with php wrapped inside <?php ?>?

No.  You put the HTML inside the Python.

Title: How does Python work?

Body:
This question may seems a little bit silly, but what the heck.

I started to learn Python. I know basic syntax, etc.

When I work with HTML, PHP, etc., I simply write code, put it inside .html or .php file and double click this file. Then my code runs. I can work with databases and other stuff - it's just simple. But how does Python work? I'm working inside Eclipse or Python command line and I can run this code, but what if I want make website with Python for example?

I don't think it's like I put .py file on my server, so what I need to do? I understand I need to install Python on my webserver through some server command line (I've never used it, but I will find some tutorials day I will need it) but what's next? How can I combine my Python knowledge with HTML, CSS, PHP, etc.?

Python may also be used to create desktop apps, what then? Can I export .exe file with Python code or what?

Any links with content describing my concerns are welcome!


答:
I have worked in both and there are plenty of reasons VFP is less desirable to build applications in.  Here are a few.

2GB table size limitation

Forms, code, everything very tightly coupled to the data.

If you are going to use it as just a front end to other data sources i.e. sql server then .Net offers much more flexibility.

Availability of developers, I have found that there are very few people left developing in VFP.

And of course there are no more future versions being released.

Title: Comparing Visual Foxpro with .NET

Body:
I used Foxpro 2.6 a decade ago. In my present company, few new  projects are being developed in Visual Foxpro 9.0 and few projects are on .NET platform. From time-to-time I notice how Visual Foxpro is more powerful as compared to .NET when comparing dependency issues.

Here are some of the advantages of VFP I noticed:

There is no hard and fast rule to use another full-fledged RDBMS. Even though the latest version of Visual Foxpro can be connected to SQL Server, but I have seen very large projects still, happily, using the old DBF. With .NET you have to connect to another RDBMS and it just adds to your Setup dependency.

Foxpro has built-in rich reporting capability since the time of DOS era, whereas .NET developers have to depend on Crystal Reports, SSRS or other third-party variants.

Visual Foxpro 9.0 has .NET capabilities as well. However, it is not dependent on .NET and therefore your final executable doesn't need .NET framework installed, which is again a dependency.

I have seen very large databases of Foxpro in few major government organizations, successfully running from a long time. These organizations don't feel a need to shift to SQL Server, not because of migration risks, but because they are happy with VFP.

I want to step into VFP world but I read somewhere that Microsoft is stopping further developments of VFP and also stopping support to VFP 9.0 from 2015 onwards.

What you guys suggest?


问:
Next in Concurrency
For past year I have been working a lot on concurrency in Java and have build and worked on many concurrent packages. So in terms of development in the concurrent world, I am quite confident. Further I am very much interested to learn and understand more about concurrent programming.

But I am unable to answer myself what next? What extra should I learn or work on to inherit more skills related to Multi-core processing. If there is any nice book (read and enjoyed 'concurrency in practice' and 'concurrent programming in java') or resource's related to Multi-core processing so that I can go to the next level?

答:
Disclaimer - I'm not a concurrency expert, but my co-author is, I'm parroting him :-)

Since you've read Doug Lea's and Brian Goetz's books then you've definitely covered the best  material out there to date.

Going forwards, there's the new concurrency enhancements in Java 7. Most noticeably the Fork/Join framework and the new asynchronous NIO APIs.

Java 8 will introduce further concurrency improvements with lambdas/parallel collections.

Another thing to seriously look at is alternative ways of dealing with concurrency. To be blunt, Java's 'lock mutable objects' approach is always going to be error prone, no matter how much the APIs are improved.  So I recommend looking at Scala's actor model and Clojure's STM as alternative ways to deal with concurrency issues whilst maintaining interoperability with Java.

[warning --> self advertisement]So I'll naturally recommend our upcoming book, The Well-Grounded Java Developer, which covers all of the things I mentioned above :-).[/warning]

Lest I forget, Groovy also has a highly recommended Gpars lib, I haven't used it personally though.

Title: Next in Concurrency


问:
When is a version control commit too large?
I've heard in several places "Don't make large commits" but I've never actually understood whats a "large" commit. Is it large if you work on a bunch of files even if there related? How many parts of a project should you be working on at once?

To me, I have trouble trying to make "small commits" since I forget or create something that creates something else that creates something else. You then end up with stuff like this:

```
Made custom outgoing queue

Bot
-New field msgQueue which is nothing more than a SingleThreadExecutor
-sendMsg blocks until message is sent, and adds wait between when messages get
sent
-adminExist calls updated (see controller)
-Removed calles to sendMessage

Controller
-New field msgWait denotes time to wait between messages
-Starting of service plugins moved to reloadPlugins
-adminExists moved from Server because of Global admins. Checks at the channel,
server, and global level

Admin
-New methods getServer and getChannel that get the appropiate object Admin
belongs to

BotEvent
-toString() also show's extra and extra1

Channel
-channel field renamed to name
-Fixed typo in channel(int)

Server
-Moved adminExists to Controller

PluginExecutor
-Minor testing added, will be removed later

JS Plugins
-Updated to framework changes
-Replaced InstanceTracker.getController() with Controller.instance
-VLC talk now in own file

Various NB project updates and changes

---

Affected files
Modify  /trunk/Quackbot-Core/dist/Quackbot-Core.jar
Modify  /trunk/Quackbot-Core/dist/README.TXT
Modify  /trunk/Quackbot-Core/nbproject/private/private.properties
Modify  /trunk/Quackbot-Core/nbproject/private/private.xml
Modify  /trunk/Quackbot-Core/src/Quackbot/Bot.java
Modify  /trunk/Quackbot-Core/src/Quackbot/Controller.java
Modify  /trunk/Quackbot-Core/src/Quackbot/PluginExecutor.java
Modify  /trunk/Quackbot-Core/src/Quackbot/info/Admin.java
Modify  /trunk/Quackbot-Core/src/Quackbot/info/BotEvent.java
Modify  /trunk/Quackbot-Core/src/Quackbot/info/Channel.java
Modify  /trunk/Quackbot-Core/src/Quackbot/info/Server.java
Modify  /trunk/Quackbot-GUI/dist/Quackbot-GUI.jar
Modify  /trunk/Quackbot-GUI/dist/README.TXT
Modify  /trunk/Quackbot-GUI/dist/lib/Quackbot-Core.jar
Modify  /trunk/Quackbot-GUI/nbproject/private/private.properties
Modify  /trunk/Quackbot-GUI/nbproject/private/private.xml
Modify  /trunk/Quackbot-GUI/src/Quackbot/GUI.java
Modify  /trunk/Quackbot-GUI/src/Quackbot/log/ControlAppender.java
Delete  /trunk/Quackbot-GUI/src/Quackbot/log/WriteOutput.java
Modify  /trunk/Quackbot-Impl/dist/Quackbot-Impl.jar
Modify  /trunk/Quackbot-Impl/dist/README.TXT
Modify  /trunk/Quackbot-Impl/dist/lib/Quackbot-Core.jar
Modify  /trunk/Quackbot-Impl/dist/lib/Quackbot-GUI.jar
Modify  /trunk/Quackbot-Impl/dist/lib/Quackbot-Plugins.jar
Modify  /trunk/Quackbot-Impl/lib/javarebel.stats
Add /trunk/Quackbot-Impl/lib/jrebel.info
Modify  /trunk/Quackbot-Impl/nbproject/private/private.properties
Modify  /trunk/Quackbot-Impl/nbproject/private/private.xml
Modify  /trunk/Quackbot-Impl/nbproject/project.properties
Modify  /trunk/Quackbot-Impl/plugins/CMDs/Admin/reload.js
Add /trunk/Quackbot-Impl/plugins/CMDs/Operator/hostBan
Modify  /trunk/Quackbot-Impl/plugins/CMDs/Operator/mute.js
Modify  /trunk/Quackbot-Impl/plugins/CMDs/lyokofreak/curPlaying.js
Modify  /trunk/Quackbot-Impl/plugins/CMDs/lyokofreak/lfautomode.js
Modify  /trunk/Quackbot-Impl/plugins/listeners/onJoin.js
Modify  /trunk/Quackbot-Impl/plugins/listeners/onQuit.js
Modify  /trunk/Quackbot-Impl/plugins/testCase.js
Add /trunk/Quackbot-Impl/plugins/utils/whatsPlaying.js
Modify  /trunk/Quackbot-Impl/src/Quackbot/impl/SandBox.java
Add /trunk/Quackbot-Impl/vlc_http
Add /trunk/Quackbot-Impl/vlc_http/current.html
Modify  /trunk/Quackbot-Plugins/dist/Quackbot-Plugins.jar
Modify  /trunk/Quackbot-Plugins/dist/README.TXT
Modify  /trunk/Quackbot-Plugins/dist/lib/Quackbot-Core.jar
Modify  /trunk/Quackbot-Plugins/nbproject/private/private.properties
Modify  /trunk/Quackbot-Plugins/nbproject/private/private.xml
Modify  /trunk/Quackbot-Plugins/src/Quackbot/plugins/JSPlugin.java
Add /trunk/Quackbot-Plugins/vlc_http
Add /trunk/global-lib/jrebel.jar
```

Yea....

So for questions:

What are some factors for when a commit becomes too large (non-obvious stuff)?

How can you prevent such commits? Please give specifics

What about when your in semi-early stages of development when things are moving quickly? Are huge commits still okay?

答:
Large commits are when you have tons of changes that don't really all go in the same bucket. If I change the controller logic, then the database connection model, then some misc. scripts, I shouldn't be  bundling it all under one commit.

Prevention is making commits according to what you're completing. In the above example I would commit after the controller logic, after the database work, and after the scripts. Don't put off committing simply because you know what changed. Other people will look back at your "Changed stuff" commit log message and wonder what you were smoking.

Initial imports are probably the biggest commits you should ever have. Setting up a system from scratch? Sure have a few big commits. After you've leveled it out though it's time to keep things organized.


答: You can also provide the system on an appliance box, the way barracuda does. (see http://www.barracudanetworks.com/ns/products/spam_overview.php)</p>


答: Another option is to provide an API on your own server, then have a web server on a local server, and that server serves the web requests for thwe clients. The API could contain all your proprietary bits, and the web server could just be presentation layer. </p>


答:
I recommend this kind of branch scheme:

release - test - development

Then from development, branch by developer and/or by feature.

Developers each have a branch to play with, and merge from, and then into into the development branch routinely - ideally every day (providing it compiles).

This sort  of scheme works really well with lots of developers and multiple projects on the same codebase.

Title: To branch or not to branch?


答:
I've used recursion heavily in game playing AI. Writing in C++, I made use of a series of about 7 functions that call each other in order (with the first function having an option to bypass all of those and call instead a chain of 2 more functions). The final function in either chain called the first function again until the remaining depth I wanted to search went to 0, in which case the final function would call my evaluation function and return the score of the position.

The multiple functions allowed me to easily branch based on either player decisions or random events in the game. I'd make use of pass-by-reference whenever I could, because I was passing around very large data structures, but because of how the game was structured, it was very difficult to have an "undo move" in my search, so I'd use pass-by-value in some functions to keep my original data unchanged. Because of this, switching to a loop-based approach instead of a recursive approach proved too difficult.

You can see a very basic outline of this sort of program, see https://secure.wikimedia.org/wikipedia/en/wiki/Minimax#Pseudocode

Title: Recursion without factorial, Fibonacci numbers etc

Body:
Almost every article I can find about recursion includes the examples of factorial or Fibonacci Numbers, which are:

Math

Useless in real life

Are there some interesting non-math code examples to teach recursion?

I'm thinking divide-and-conquer algorithms but they usually involve complex data structures.


答: Another real world recursion problem that students may relate to is to build their own web crawler that pulls information from a website and follows all the links within that site (and all the links from those links, etc). </p>


答:
I was mostly a VFP developer (from FPDOS) until this year so I can understand where your coming from.

The problem as I see it isn't capability. As it is, VFP is able to deal with most requirements without flinching, sometimes even outperforming the more popular alternatives.

The problem is the marketplace and the changing environment. In the eyes of most people, VFP is no longer part of the Microsoft "stack". That means your salespeople will meet greater resistance as time goes on. It also means less and less people will be learning the language, which means you might have support issues even if its an in house application.

I love VFP and still curse at random moments when I'm working with C# and .NET but it was something that had to be done. Sticking to VFP would have just been delaying the inevitable. Sooner or later, it WILL become an issue and if that's going to be the case, you might as well make the switch now.

Title: Comparing Visual Foxpro with .NET


答: Take a look at the Scala language, which extends Java and runs on the JVM.  It borrows the notion of "Actors" from Erlang, and gives good capability for handling concurrency failures.</p>

Title: Next in Concurrency

Body:
For past year I have been working a lot on concurrency in Java and have build and worked on many concurrent packages. So in terms of development in the concurrent world, I am quite confident. Further I am very much interested to learn and understand more about concurrent programming.

But I am unable to answer myself what next? What extra should I learn or work on to inherit more skills related to Multi-core processing. If there is any nice book (read and enjoyed 'concurrency in practice' and 'concurrent programming in java') or resource's related to Multi-core processing so that I can go to the next level?


答:
There is no hard and fast rule to use another full-fledged RDBMS. Even
  though the latest version of Visual Foxpro can be connected to SQL
  Server, but I have seen very large projects still, happily, using the
  old DBF. With .NET you have to connect to another RDBMS and it just
  adds to your Setup dependency.

no you don't have to connect to anything :) . This is fine if you want tight coupling of data/application as others have mentioned. However from a design prespective this breaks down quickly when you want to scale the application. What happens when you have a very heterogeneous system that has to interconnect to multiple platforms? web/desktop/mobile etc. In this case de-coupling the code from the data-store is the normal route.

Foxpro has built-in rich reporting capability since the time of DOS
  era, whereas .NET developers have to depend on Crystal Reports, SSRS
  or other third-party variants.

Again, you don't have to depend on anything. Most "reports" are either spreadsheets or pdf (insert other format). As you have mentioned 3rd party components are available. Most projects I've worked on  use custom built solutions, code-reuse means that the investment is one off.

Visual Foxpro 9.0 has .NET capabilities as well. However, it is not
  dependent on .NET and therefore your final executable doesn't need
  .NET framework installed, which is again a dependency.

If you are targeting the Windows platform, this is a poor argument. Further there are solutions that can run .NET without needing the .NET runtime e.g http://spoon.net/ or others that bundle everything into a single executable. Using silverlight/Asp.net you could also host your application as a thin client.

I have seen very large databases of Foxpro in few major government
  organizations, successfully running from a long time. These
  organizations don't feel a need to shift to SQL Server, not because of
  migration risks, but because they are happy with VFP.

Many companies are also happy with COBOL, however things have improved vastly since then. When the option is available to use newer technology platform, there are no real reason to use legacy platforms.

Title: Comparing Visual Foxpro with .NET


答:
As long as it needs to last, no less and no more. Anything else isn't Agile.

If you have a team of 2 - 3 developers and are doing 1 week sprints anything more than a hour is probably counter productive.

If you have a team of 15 people and 2 weeks sprints you are looking at all day, anything less isn't detailed enough.

It takes experience to get it mostly right, and that is what retrospectives are for, the team decides what is too long or too short.

Don't worry about getting it perfect or sticking to what some book says, try something and refine it.

SCRUM is about refining the process in iterations as much as it is about refining your code in iterations.

Title: How long should a sprint planning meeting last?

Body: In your experience, how long should a Sprint Planning meeting (Scrum) last? 8 hours? Or should it be shorter (succinct) and further discussions should be planned as part of the sprint? Our Sprints are 10 days long.</p>


问:
Is there a specific design strategy that can be applied to solve most chicken-and-egg problems while using immutable objects?
Coming from a OOP background (Java), I'm learning Scala on my own. While I can readily see the advantages of using immutable objects individually, I'm having a hard time seeing how one can design a whole application like that. I'll give an example:

Say I have objects that represents "materials" and their properties (I'm designing a game, so I actually really have that problem), like water and ice. I would have a "manager" that owns all such materials instances. One property would be the freezing and melting point, and what the material freezes or melts to.

[EDIT] All material instances are "singleton", kind of like a Java Enum.

I want "water" to say it freezes to "ice" at 0C, and "ice" to say it melts to "water" at 1C. But if water and ice are immutable, they cannot get a reference to each other as constructor parameters, because one of them has to be created first, and that one could not get a reference to the not-yet-existing other as constructor parameter. I could solve this by giving them both a reference to the manager so that they can query it to find the other material instance they need every time they are being asked for their freezing/melting properties, but then I get the same problem between the manager and the materials, that they need a reference to each other, but it can only be provided in the constructor for one of them, so either the manager or the material cannot be immutable.

Is their just no way around this problem, or do I need to use "functional" programming techniques, or some other pattern to solve it?

答:
If you're going to use a functional language, and you want to realize the benefits of immutability, then you should approach the problem with that in mind. You're attempting to define an object type "ice" or "water" that can support a range of temperatures - in order to support immutability, you'd then need to create a new object every time the temperature changes, which is wasteful. So try to make the concepts of block-type and temperature more independent. I don't know Scala (it's on my to-learn list :-) ), but borrowing from Joey Adams Answer in Haskell, I suggest something like:

```<code>data Material = Water | Ice

blockForTemperature :: Double -> Material
blockForTemperature x =
  if x < 0 then Ice else Water
</code>```

or maybe:

```<code>transitionForTemperature :: Material -> Double -> Material
transitionForTemperature oldMaterial newTemp =
  case (oldMaterial, newTemp) of
    (Ice, _) | newTemp > 0 -> Water
    (Water, _) | newTemp <= 0 -> Ice
</code>```

(Note: I haven't tried to run this, and my Haskell's a little rusty.) Now, the transition logic is separated from the material type, so it doesn't waste as much memory, and (in my opinion) it's quite a bit more functionally oriented.

Body:
If you're going to use a functional language, and you want to realize the benefits of immutability, then you should approach the problem with that in mind. You're attempting to define an object type "ice" or "water" that can support a range of temperatures - in order to support immutability, you'd then need to create a new object every time the temperature changes, which is wasteful. So try to make the concepts of block-type and temperature more independent. I don't know Scala (it's on my to-learn list :-) ), but borrowing from Joey Adams Answer in Haskell, I suggest something like:

data Material = Water | Ice

blockForTemperature :: Double -> Material
blockForTemperature x =
  if x < 0 then Ice else Water

or maybe:

transitionForTemperature :: Material -> Double -> Material
transitionForTemperature oldMaterial newTemp =
  case (oldMaterial, newTemp) of
    (Ice, _) | newTemp > 0 -> Water
    (Water, _) | newTemp <= 0 -> Ice

(Note: I haven't tried to run this, and my Haskell's a little rusty.) Now, the transition logic is separated from the material type, so it doesn't waste as much memory, and (in my opinion) it's quite a bit more functionally oriented.


答:
To me, I have trouble trying to make "small commits" since I forget or create something that creates something else that creates something else.

That is a problem.  It sounds like you need to learn to break down your work into smaller, more manageable chunks.

The problem with large commits are:

In a multi-person project, a greater chance that your commits will cause conflicts for other developers to resolve.

It is harder to accurately describe what has been done in log messages.

It is harder to track the order that changes were made, and hence to understand the cause of problems.

It increases the probability of losing a lot of uncommitted work.

Sometimes large commits are unavoidable; e.g. if you have to change a major API.  But that's not normally the case.  And if you do find yourself in this situation, it is probably a good idea to create a branch and do your work in there ... with lots of small commits ... and reintegrate when you are finished.

(Another case is when you do an initial import, but that's NOT problematical from the perspective of the issues listed above.)

Title: When is a version control commit too large?

Body:
I've heard in several places "Don't make large commits" but I've never actually understood whats a "large" commit. Is it large if you work on a bunch of files even if there related? How many parts of a project should you be working on at once?

To me, I have trouble trying to make "small commits" since I forget or create something that creates something else that creates something else. You then end up with stuff like this:

```
Made custom outgoing queue

Bot
-New field msgQueue which is nothing more than a SingleThreadExecutor
-sendMsg blocks until message is sent, and adds wait between when messages get
sent
-adminExist calls updated (see controller)
-Removed calles to sendMessage

Controller
-New field msgWait denotes time to wait between messages
-Starting of service plugins moved to reloadPlugins
-adminExists moved from Server because of Global admins. Checks at the channel,
server, and global level

Admin
-New methods getServer and getChannel that get the appropiate object Admin
belongs to

BotEvent
-toString() also show's extra and extra1

Channel
-channel field renamed to name
-Fixed typo in channel(int)

Server
-Moved adminExists to Controller

PluginExecutor
-Minor testing added, will be removed later

JS Plugins
-Updated to framework changes
-Replaced InstanceTracker.getController() with Controller.instance
-VLC talk now in own file

Various NB project updates and changes

---

Affected files
Modify  /trunk/Quackbot-Core/dist/Quackbot-Core.jar
Modify  /trunk/Quackbot-Core/dist/README.TXT
Modify  /trunk/Quackbot-Core/nbproject/private/private.properties
Modify  /trunk/Quackbot-Core/nbproject/private/private.xml
Modify  /trunk/Quackbot-Core/src/Quackbot/Bot.java
Modify  /trunk/Quackbot-Core/src/Quackbot/Controller.java
Modify  /trunk/Quackbot-Core/src/Quackbot/PluginExecutor.java
Modify  /trunk/Quackbot-Core/src/Quackbot/info/Admin.java
Modify  /trunk/Quackbot-Core/src/Quackbot/info/BotEvent.java
Modify  /trunk/Quackbot-Core/src/Quackbot/info/Channel.java
Modify  /trunk/Quackbot-Core/src/Quackbot/info/Server.java
Modify  /trunk/Quackbot-GUI/dist/Quackbot-GUI.jar
Modify  /trunk/Quackbot-GUI/dist/README.TXT
Modify  /trunk/Quackbot-GUI/dist/lib/Quackbot-Core.jar
Modify  /trunk/Quackbot-GUI/nbproject/private/private.properties
Modify  /trunk/Quackbot-GUI/nbproject/private/private.xml
Modify  /trunk/Quackbot-GUI/src/Quackbot/GUI.java
Modify  /trunk/Quackbot-GUI/src/Quackbot/log/ControlAppender.java
Delete  /trunk/Quackbot-GUI/src/Quackbot/log/WriteOutput.java
Modify  /trunk/Quackbot-Impl/dist/Quackbot-Impl.jar
Modify  /trunk/Quackbot-Impl/dist/README.TXT
Modify  /trunk/Quackbot-Impl/dist/lib/Quackbot-Core.jar
Modify  /trunk/Quackbot-Impl/dist/lib/Quackbot-GUI.jar
Modify  /trunk/Quackbot-Impl/dist/lib/Quackbot-Plugins.jar
Modify  /trunk/Quackbot-Impl/lib/javarebel.stats
Add /trunk/Quackbot-Impl/lib/jrebel.info
Modify  /trunk/Quackbot-Impl/nbproject/private/private.properties
Modify  /trunk/Quackbot-Impl/nbproject/private/private.xml
Modify  /trunk/Quackbot-Impl/nbproject/project.properties
Modify  /trunk/Quackbot-Impl/plugins/CMDs/Admin/reload.js
Add /trunk/Quackbot-Impl/plugins/CMDs/Operator/hostBan
Modify  /trunk/Quackbot-Impl/plugins/CMDs/Operator/mute.js
Modify  /trunk/Quackbot-Impl/plugins/CMDs/lyokofreak/curPlaying.js
Modify  /trunk/Quackbot-Impl/plugins/CMDs/lyokofreak/lfautomode.js
Modify  /trunk/Quackbot-Impl/plugins/listeners/onJoin.js
Modify  /trunk/Quackbot-Impl/plugins/listeners/onQuit.js
Modify  /trunk/Quackbot-Impl/plugins/testCase.js
Add /trunk/Quackbot-Impl/plugins/utils/whatsPlaying.js
Modify  /trunk/Quackbot-Impl/src/Quackbot/impl/SandBox.java
Add /trunk/Quackbot-Impl/vlc_http
Add /trunk/Quackbot-Impl/vlc_http/current.html
Modify  /trunk/Quackbot-Plugins/dist/Quackbot-Plugins.jar
Modify  /trunk/Quackbot-Plugins/dist/README.TXT
Modify  /trunk/Quackbot-Plugins/dist/lib/Quackbot-Core.jar
Modify  /trunk/Quackbot-Plugins/nbproject/private/private.properties
Modify  /trunk/Quackbot-Plugins/nbproject/private/private.xml
Modify  /trunk/Quackbot-Plugins/src/Quackbot/plugins/JSPlugin.java
Add /trunk/Quackbot-Plugins/vlc_http
Add /trunk/global-lib/jrebel.jar
```

Yea....

So for questions:

What are some factors for when a commit becomes too large (non-obvious stuff)?

How can you prevent such commits? Please give specifics

What about when your in semi-early stages of development when things are moving quickly? Are huge commits still okay?


问:
THREADS: Kernel threads vs. Kernel-supported threads vs. User-level threads?
Does anyone know what the difference between these are?

It seems to me that kernel threads correspond to the code that runs the kernel (intuitively), but I'm not sure about the other two...

Also, would the pthreads standard be considered user-level and kernel-supported, since you are accessing a library while the kernel does all the thread scheduling/switching?

答:
The term "kernel threads" can be used to refer to actual threads that run entirely in kernel space or it can refer to user-space threads scheduled by the kernel. The term "kernel-supported" threads means the latter, threads that run in user-space but are facilitated by the kernel, which usually means the kernel schedules them.

"User-level threads" usually means threads visible to user space. That is, what you create when you call your threading standard's "create thread" function. Generally, the term "user-level thread" is used to mean a thread created by the application code regardless of how it's implemented by the system. It may be a pure user-space thread with little to no kernel support or it may be a thread scheduled by the kernel.

The pthreads standard can be implemented as pure user-space threads (where the kernel schedules the process and the process schedules the threads), kernel-supported threads (where the kernel schedules the threads directly), or a hybrid approach (where the kernel schedules a kernel-level thread which then, in user-space, schedules a user-level thread). The standard doesn't demand any one particular means of implementation. The most common implementation is 1-to-1 mapping where each user-level thread has a corresponding thread that is scheduled by the kernel.


答:
Can I export .exe file with Python code or what?

py2exe turns Python programs into packages that can be run on other Windows computers without needing to install Python on those computers. Python is needed on the computer where py2exe itself is run because py2exe is a Python program and it includes parts of Python in the package that is built.  http://www.py2exe.org/index.cgi/Tutorial

Jython is an implementation of the Python programming language which is designed to run on the Java(tm) Platform. It consists of a compiler to compile Python source code down to Java bytecodes which can run directly on a JVM, a set of support libraries which are used by the compiled Java bytecodes, and extra support to make it trivial to use Java packages from within Jython.  http://www.jython.org/index.html

Title: How does Python work?


问:
What is O in Big O?
What is Big and O in Big O notation? I've read the definitions and it doesn't tell what is O pronounced as 'oh'.  For example - I understand that O(n) is complexity of a linear algorithm where n could be the number of operations. but what is an O?

答:
Well, my guess would be order, which coincides with wikipedia.

Edit: (my own (any improvements appreciated)) translation from the German wikipedia article

The capital letter O (actually a capital omicron at the time) as a
  symbol for the order of (German: "Ordnung von") was first used by the
  German number theorist Paul Bachman in the second  issue of his book
  on analytic number theory appeared in 1894. The notation gained
  popularity due to the work of Edmund Landau, another German number
  theorist, whom this nomenclature is widely associated with today,
  especially in the German terminology.

Title: What is O in Big O?


答:
If you want to take it to a whole new level, you might want to look into programming with CUDA.

This allows you to distribute your algorithms over hundreds of processing cores on your graphics card rather than the few main CPU cores. There are even Language bindings which apparently make it relatively easy to accelerate high level languages like python using GPGPU techniques.

Title: Next in Concurrency


答:
I like this article, hoping you would find it useful too!

Quoting a section from the article:

Big Greek Letters

Big O is often misused. Big O or Big Oh is actually short for Big Omicron. It represents the upper bound of asymptotic complexity. So if an algorithm is O(n log n) there exists a constant c such that the upper bound is cn log n.

Θ(n log n) (Big Theta) is more tightly bound than that. Such an algorithm means there exists two constants c1 and c2 such that c1n log n < f(n) < c2n log n.

Ω(n log n) (Big Omega) says that the algorithm has a lower bound of cn log n.

There are others but these are the most common and Big O is the most common of all. Such a distinction is typically unimportant but it is worth noting. The correct notation is the correct notation, after all.

What is Big O?

Big O notation seeks to describe the relative complexity of an algorithm by reducing the growth rate to the key factors when the key factor tends towards infinity. For this reason, you will often hear the phrase asymptotic complexity. In doing so, all other factors are ignored. It is a  relative representation of complexity.

What Isn’t Big O?

Big O isn’t a performance test of an algorithm. It is also notional or abstract in that it tends to ignore other factors. Sorting algorithm complexity is typically reduced to the number of elements being sorted as being the key factor. This is fine but it doesn’t take into account issues such as:

Memory Usage: one algorithm might use much more memory than another. Depending on the situation this could be anything from completely irrelevant to critical;
Cost of Comparison: It may be that comparing elements is really expensive, which will potentially change any real-world comparison between algorithms;
Cost of Moving Elements: copying elements is typically cheap but this isn’t necessarily the case;
etc.

Title: What is O in Big O?

Body: What is Big and O in Big O notation? I've read the definitions and it doesn't tell what is O pronounced as 'oh'.  For example - I understand that O(n) is complexity of a linear algorithm where n could be the number of operations. but what is an O?


答:
"Big" means "capital", and "O" means order, as in "order of complexity".  So named because of the convention of writing "order of complexity" as O(f(x)), e.g., with a capital letter 'O', or a 'Big O'.  Nobody talks about it much because 'everyone' understands what it means, and understanding it doesn't really help you understand complexity analysis.

For an understanding of complexity analysis, I think the link posted by topgun_ivard is a good place to start.  A good introductory textbook covering data structures or algorithms might also help.

Title: What is O in Big O?


问:
What can you do to decrease the number of deployment bugs of a live website?
I'm sure lots of you have experienced this problem. A website or web application is running and is live. You want to upload the next version, but you haven't figured out everything, like setting a value to false in configuration file, inserting another record into the database, and doing lots of minor stuff which can sometimes count to 20 or more parameters.

As soon as you upload the new version, everything breaks. Now, fixing the problem may only take up to 20 minutes, but the overall stress that you tolerate, and the financial and goodwill damage to the company are sometimes not forgettable.

What are the ways to reduce these types of bugs which arise from the initial configuration of new version deployment?

PS: Please don't mention check-lists, cause we already have them. The problem with check-lists is that, they should always get updated, but they won't.

答:
For something that absolutely, positively must not break consider having an A and a B system and use a load balancer to route all requests to A while you upgrade and test B, and then route everything to B while you update A.

For bonus points, add C and ensure your systems are geographically separated so an earthquake won't take 2 of them out simultaneously.

For many applications, I admit that this is overkill.

It also complicates any transaction management you need to do, but the problems are not insurmountable.


问:
To branch or not to branch?
Till recently my development workflow was the following:

Get the feature from product owner

Make a branch (if feature is more than 1 day)

Implement it in a branch

Merge changes from main branch to my branch (to reduce conflicts during backward merging)

Merge my branch back to main branch

Sometimes there were problems with merging, but in general I liked it.

But recently I see more and more followers of idea to not make branches as it makes more difficult to practice continuous integration, continuous delivery, etc. And it sounds especially funny from people with distributed VCS background who were talking so much about great merging implementations of Git, Mercurial, etc.

So the question is should we use branches nowadays?

答:
Unless you are all working out of the same working tree, you are using branches, whether you call them that or not.  Every time a developer checks out into his working tree, he creates a separate local branch of development, and every time he checks in he does a merge.  For most teams, the question isn't if you use branches, the questions are how many and for what purpose?

The only way to do truly "continuous" integration is for everyone to work out of the same working tree.  That way, you immediately know if your changes adversely impact someone else's.  Obviously, that's untenable.  You need a certain degree of isolation in a branch in order to accomplish anything, even if that "branch" is just your local working directory.  What's needed is a proper balance of integration and isolation.

In my experience, using more branches improves the degree of integration, because the integration is done with precisely the people it needs to be done, and everyone else can more easily isolate non-related problems as required.

For example, I spent the last day tracking down three recently introduced integration-related bugs in our build that were blocking my "real" work.  Having done my due diligence in reporting these bugs to the people who need to fix them, am I now just supposed to wait until they are finished to continue my work?  Of course not.  I created a temporary local branch that reverts those changes so I can have a stable baseline to work against while still receiving the latest changes from upstream.

Without the ability to make a new branch for that purpose, I would be reduced to one of three options:  either revert the changes in the central repo, manually maintain the patches that revert them in my working tree and try not to accidentally check them in, or back out to a version before those bugs were introduced.  The first option is likely to break some other dependency.  The second option is a lot of work, so most people choose the third option, which essentially prevents you from doing more integration work until the previously found bugs are fixed.

My example used a private local branch, but the same principle applies to shared branches.  If I share my branch, then maybe 5 other people are able to continue on with their primary tasks instead of performing redundant integration work, thus in aggregate more useful integration work is performed.  The issue with branching and continuous integration isn't how many branches you have, it's how frequently you merge them.

Title: To branch or not to branch?


问:
What other languages, beside Transact SQL, state that 22/7 is equal to 3?
I was using Microsoft SQL Query Analyzer the other day and wrote a very simple select statement:

```<code>SELECT 22/7 as [PI Equiv]
</code>```

I was suprized that the result was 3, when I was expecting to see 3.1428571. Even if you declare the output to be Numeric(18,7), you still get 3.0000000.

```<code>DECLARE @Answer Numeric(18,7)
SET @Answer = 22/7
SELECT @Answer as [PI Equiv]

RESULT = 3.0000000
</code>```

What other languages return integer values when the dividend and divisor are both integers?

答:
Python 2.x (without the -Q new option or from __future__ import division)

```<code>>>> 22/7
3
</code>```

bash

```<code>$ expr 22 / 7
3
</code>```

Java

```<code>class Div{
    public static void main( String[] args ) {
        int x = 22/7;
        System.out.println( "22/7=" + x );
    }
}

$ java Div
22/7=3
</code>```

Body:
Python 2.x (without the -Q new option or from __future__ import division)

>>> 22/7
3

bash

$ expr 22 / 7
3

Java

class Div{
    public static void main( String[] args ) {
        int x = 22/7;
        System.out.println( "22/7=" + x );
    }
}

$ java Div
22/7=3


答: If you know you are going to be working on a large chunk of code beforehand, I would suggest creating a branch for your specific feature while periodically pulling code down from the mainline to make sure your code stays in-sync. When you're done working on the branch merge all your changes back into the mainline. This way other team members will not be surprised and/or annoyed when they see a huge commit. Also, there's a much less chance of breaking things. Keep practicing to break things down into smaller commits. With time it will become second nature.</p>


问:
Should we encourage coding styles in favor of developer's autonomy, or discourage it in favor of consistency?
A developer writes if/else blocks with one-line code statements like:

```<code>if (condition)
   // Do this one-line code
else
   // Do this one-line code
</code>```

Another uses curly braces for all of them:

```<code>if (condition)
{
   // Do this one-line code
}
else
{
   // Do this one-line code
}
</code>```

A developer first instantiates an object, then uses it:

```<code>HelperClass helper = new HelperClass();
helper.DoSomething();
</code>```

Another developer instantiates and uses the object in one line:

```<code>new HelperClass().DoSomething();
</code>```

A developer is more easy with arrays, and for loops:

```<code>string[] ordinals = new string[] {'First', 'Second', 'Third'};
for (i = 0; i < ordinals.Length; i++)
{
    // Do something
}
</code>```

Another writes:

```<code>List<string> ordinals = new List<string>() {'First', 'Second', 'Third'};
foreach (string ordinal in ordinals)
{
    // Do something
}
</code>```

I'm sure that you know what I'm talking about. I call it coding style (cause I don't know what it's called). But whatever we call it, is it good or bad? Does encouraging it have an effect of higher productivity of developers? Should we ask developers to try to write code the way we tell them, so to make the whole system become style-consistent?

答:
Create consistency with a good upfront design.  What you describe in the question is nothing less than micro-management.  I do a lot of web development.  So I favor RESTful and CRUD development exposed as services.  This ensures simple, well defined entities that can be used in a variety of ways.

This design also allows me to delegate implementation details to other developers. This way they are filling in the blanks rather than creating a whole system design.

A lack of an overall design creates system inconsistencies.  Critique of basic iterations and looping constructs does little to improve system design.  These kinds of problems are better solved with a hands off approach, StyleCop.

Can you draw a relatively simple diagram of your overall system design?  A design describing the elements/entities involved in a to a new team developer.  If you cannot, or it is highly involved then the design is lacking.


答:
"f(x) is big-oh of g(x)"

It is a mathematical way to predict the growth of functions.

Let f and g be functions from the set of integers or the set or real numbers to the set of real numbers. We say that f(x) is O(g(x)) if there are constants C and k such that  |f(x)| <= C|g(x)| wherever x > k.

You would read this as "f(x) is big-oh of g(x)"

The big-O is sometimes called a Landau symbol after the German mathematician Edmund Landau. I don't think it stands for anything beyond that. You also have the similar big-Omega and big-Theta notations. The symbols are as arbitrary as always using theta to denote the angles in your triangles was in your high-school Planar Geometry class.

Correction
 @back2dos has provided a satisfactory explanation for the O as referring to order. Great Job. See his answer.

Donald Knuth applied it to studying the complexity of computer programs.

If you want to find the reason the notation was used, you should read

"Analytische Zahlentheorie" by Paul Bachmann from 1892

Title: What is O in Big O?


答:
Most languages that supports integer arithmetic will give you 3 from the calculation 22/7. This includes, C, C++, C#, Ada, Java, etc. The exceptions appear to be Pascal, VB and Lisp that do floating point arithmetic by default.

Languages where you have implicit typing may give you a floating point result instead, though I would check it first.

However, it's bad programming practice and if you mean floating point division you should make at least one of the values explicitly floating point:

```<code>pi = 22.0 / 7;
</code>```

Title: What other languages, beside Transact SQL, state that 22/7 is equal to 3?

Body:
I was using Microsoft SQL Query Analyzer the other day and wrote a very simple select statement:

```<code>SELECT 22/7 as [PI Equiv]
</code>```

I was suprized that the result was 3, when I was expecting to see 3.1428571. Even if you declare the output to be Numeric(18,7), you still get 3.0000000.

```<code>DECLARE @Answer Numeric(18,7)
SET @Answer = 22/7
SELECT @Answer as [PI Equiv]

RESULT = 3.0000000
</code>```

What other languages return integer values when the dividend and divisor are both integers?

Body:
Most languages that supports integer arithmetic will give you 3 from the calculation 22/7. This includes, C, C++, C#, Ada, Java, etc. The exceptions appear to be Pascal, VB and Lisp that do floating point arithmetic by default.

Languages where you have implicit typing may give you a floating point result instead, though I would check it first.

However, it's bad programming practice and if you mean floating point division you should make at least one of the values explicitly floating point:

pi = 22.0 / 7;


答:
A really good real life example in business is something called a "Bill of Materials". This is the data that represents all of the components that make up a finished product. For example, let's use a Bicycle. A Bicycle has handlebars, wheels, a frame, etc. And each of those components can have sub-components. for example the Wheel can have Spokes, a valve stem, etc. So typically these are represented in a tree structure.

Now to query any aggregate information about the BOM or to change elements in a BOM often times you resort to recursion.

```<code>    class BomPart
    {
        public string PartNumber { get; set; }
        public string Desription { get; set; }
        public int Quantity { get; set; }
        public bool Plastic { get; set; }
        public List<BomPart> Components = new List<BomPart>();
    }
</code>```

And a sample recursive call...

```<code>    static int ComponentCount(BomPart part)
    {
        int subCount = 0;
        foreach(BomPart p in part.Components)
            subCount += ComponentCount(p);
        return part.Quantity * Math.Max(1,subCount);

    }
</code>```

Obviously the BomPart Class would have many many more fields. You may need to figure out how many plastic components you have, how much labor it takes to build a complete part, etc. All this comes back to the usefulness of Recursion on a tree structure though.

Body:
A really good real life example in business is something called a "Bill of Materials". This is the data that represents all of the components that make up a finished product. For example, let's use a Bicycle. A Bicycle has handlebars, wheels, a frame, etc. And each of those components can have sub-components. for example the Wheel can have Spokes, a valve stem, etc. So typically these are represented in a tree structure.

Now to query any aggregate information about the BOM or to change elements in a BOM often times you resort to recursion.

    class BomPart
    {
        public string PartNumber { get; set; }
        public string Desription { get; set; }
        public int Quantity { get; set; }
        public bool Plastic { get; set; }
        public List<BomPart> Components = new List<BomPart>();
    }

And a sample recursive call...

    static int ComponentCount(BomPart part)
    {
        int subCount = 0;
        foreach(BomPart p in part.Components)
            subCount += ComponentCount(p);
        return part.Quantity * Math.Max(1,subCount);

    }

Obviously the BomPart Class would have many many more fields. You may need to figure out how many plastic components you have, how much labor it takes to build a complete part, etc. All this comes back to the usefulness of Recursion on a tree structure though.


答:
A well executed release is all about planning and communication. So prior to conducting a release consider these questions:

How long is the release likely to take, and are there any risks in letting people continue to interface with my product while the release is underway? If there is a risk to the system, consider taking the system offline and putting up a "System in currently undergoing maintenance" message in its place.

Are there any customers you may need to notify about the release ahead of time? Do I need to tell them about a possible service interruption, or performance degradation while the release is underway? Personally I always err on the side of over-communicating and telling all customers about an upcoming release or maintenance window on a public blog or a similar venue.

What are my contingency plans should the release go awry? For example, if the release goes poorly should we roll back and restore the system to the way it was to minimize any time we are offline? And if so, are the steps for rolling back a release well documented? Or should I have the right people on call or on hand in order to assist with troubleshooting problems should they occur. Personally, I think the best way to approach the planning of any release is to assume something will go wrong with the release. That way I have forced myself to think through some of these issues ahead of time.

Next, when it comes to executing a release, one of the best ways to ensure that it will run smoothly is to practice, practice, practice, and to document everything you encounter along the way. So, well in advance of deploying new code to production, practice deploying the code to a secure, properly sandboxed staging environment first. Have the person who will be responsible for deploying to production, perform the test deployment to staging. Consider this your dress rehearsal and conduct yourself as you would if this is the real thing. Document everything you do every step of the way; document every command you execute, any SQL code you run, any files you modify and how you modified them and for each step along the way document what you expect to see if the procedure is executed properly. If and when you encounter a problem of some kind, document what you did to resolve it.

Then the practice deployment is complete, look over your notes and see if you can refine the process to eliminate errors. Then do it all over again. Keep practicing until executing a release becomes as routine as following a simple instruction sheet, like "login to this machine, execute this command; then login to the database and execute this SQL command; then..."

Listed above are the things an operations or release management team can do to help a release run smoothly. But what can the engineering do to help minimize the risks in a release?

Keep releases small. Simply put, the more complex the set of code changes contained by a release, the more risky the release will become. Do your operations team a favor by planning to have a larger number of small releases, rather than a smaller number of large releases over the same period of time.

Test, test, test. Don't just test your code in your QA environment, use the staging environment to test your software as well. Often there are bugs that have little or nothing to do with the code itself, but rather have a root cause that lies in the configuration of the environment itself (or some mix of the two). To find these issues you need to test your code in an environment that closely mirrors production, a.k.a. staging.

As a last word, sometimes what is most important is not what we do to prevent things from going wrong, but it is how we conduct ourselves when they do go wrong. Therefore, I think it is important to build a culture in your company around operational transparency. Don't try to hide issues from customers, be forthcoming. Use Twitter actively to let customers know if there are issues your ops team is currently aware of and working to resolve (Lighthouse is awesome at this!). Consider publishing a "status" page for your service that customers can reference to see if anything is wrong (TypePad offers a great example of this). Bottom line, always err on the side of over-communication. Your customers will thank you for it.

Title: What can you do to decrease the number of deployment bugs of a live website?

Body:
I'm sure lots of you have experienced this problem. A website or web application is running and is live. You want to upload the next version, but you haven't figured out everything, like setting a value to false in configuration file, inserting another record into the database, and doing lots of minor stuff which can sometimes count to 20 or more parameters.

As soon as you upload the new version, everything breaks. Now, fixing the problem may only take up to 20 minutes, but the overall stress that you tolerate, and the financial and goodwill damage to the company are sometimes not forgettable.

What are the ways to reduce these types of bugs which arise from the initial configuration of new version deployment?

PS: Please don't mention check-lists, cause we already have them. The problem with check-lists is that, they should always get updated, but they won't.


答:
Style doesn't matter.

There, I said it.

After 30 years, and hundreds of client sites, and code from (estimating) 500 (or more) team members over those years, I've found that style just doesn't matter.

Get it to work, first.

Get it to use an optimal volume of resources (i.e., right data structure, right algorithm).

Fuss over "style" after everything else has been solved.  Fuss of "style" only with tools, never manually.

Title: Should we encourage coding styles in favor of developer's autonomy, or discourage it in favor of consistency?

Body:
A developer writes if/else blocks with one-line code statements like:

```<code>if (condition)
   // Do this one-line code
else
   // Do this one-line code
</code>```

Another uses curly braces for all of them:

```<code>if (condition)
{
   // Do this one-line code
}
else
{
   // Do this one-line code
}
</code>```

A developer first instantiates an object, then uses it:

```<code>HelperClass helper = new HelperClass();
helper.DoSomething();
</code>```

Another developer instantiates and uses the object in one line:

```<code>new HelperClass().DoSomething();
</code>```

A developer is more easy with arrays, and for loops:

```<code>string[] ordinals = new string[] {'First', 'Second', 'Third'};
for (i = 0; i < ordinals.Length; i++)
{
    // Do something
}
</code>```

Another writes:

```<code>List<string> ordinals = new List<string>() {'First', 'Second', 'Third'};
foreach (string ordinal in ordinals)
{
    // Do something
}
</code>```

I'm sure that you know what I'm talking about. I call it coding style (cause I don't know what it's called). But whatever we call it, is it good or bad? Does encouraging it have an effect of higher productivity of developers? Should we ask developers to try to write code the way we tell them, so to make the whole system become style-consistent?


答:
In integer arithmetic, the remainder is ignored. This is standard behaviour in most modern languages, initially included in programming languages due to hardware limitations and performance constraints.

For historic and performance reasons, this behaviour is present in most modern languages/platforms; you'll have to go out of your way to find a language which doesn't behave in this manner (examples of exceptions include some experiments with  Smalltalk and related).


答:
Family relations make for good examples because everybody understands them intuitively:</p>

```<code>ancestor(joe, me) = (joe == me)
                    OR ancestor(joe, me.father)
                    OR ancestor(joe, me.mother);
</code>```

Body:
Family relations make for good examples because everybody understands them intuitively:

ancestor(joe, me) = (joe == me)
                    OR ancestor(joe, me.father)
                    OR ancestor(joe, me.mother);


问:
Are certifications worth it?
I am finishing my college degree in programming soon and I'm exploring the next steps to take to further my career. One option I've been considering is getting a certification or a series of certifications in the area of development I want to work in.

Are these certifications worth the time and money? Do employers place a lot of value in them?

答:
Well, in Italy programmers are looked as the least important part of almost any work organization, so your actual skills (including certifications) are often ignored by employers, and real life experience is much more well regarded.

In good companies however, certifications are a valuable part of your résumé.

Title: Are certifications worth it?


答:
You didn't specifically ask, but I thought I'd add that if you don't want an integer result you do this:

```<code>SELECT 22/7.0 as [PI Equiv]
</code>```

or

```<code>SELECT 22/cast(7 as numeric (18.2)) as [PI Equiv]
</code>```

Casting an output variable did nothing because the calculation is done before the variable value is set.  Division in SQL should explicitly specify that one of the elements is a decimal if you want a decimal result. You also should almost never do a division without  a case statement to make sure that the divide by 0 possibility will be handled unless the divisor is a hardcoded value such as the 7 in your calculation.

```<code>declare @somenumber numeric(18,2)
set @somenumber = 0
SELECT CASE where  @somenumber = 0 then null else 22/@somenumber end as [PI Equiv]
</code>```

Body:
You didn't specifically ask, but I thought I'd add that if you don't want an integer result you do this:

SELECT 22/7.0 as [PI Equiv]

or

SELECT 22/cast(7 as numeric (18.2)) as [PI Equiv]

Casting an output variable did nothing because the calculation is done before the variable value is set.  Division in SQL should explicitly specify that one of the elements is a decimal if you want a decimal result. You also should almost never do a division without  a case statement to make sure that the divide by 0 possibility will be handled unless the divisor is a hardcoded value such as the 7 in your calculation.

declare @somenumber numeric(18,2)
set @somenumber = 0
SELECT CASE where  @somenumber = 0 then null else 22/@somenumber end as [PI Equiv]


答: Enforcing uniform coding style is always hard.  Ideally such mundane task should be left to a tool to handle.  I applaud the Go language community for doing that.</p>


问:
When should I use a 2-property class over a pre-built structure like a KeyValuePair?
When should you put Key/Value type of data in it's own class instead of using a pre-built generic structure, such as a KeyValuePair or a Tuple?

For example, most ComboBoxes I create contain a DisplayName and a Value. This is the kind of data I am trying to decide when to put in a new class, and when to just use a KeyValuePair.

I am currently working on something that uses iCalendar, and the selected user's data ultimately gets combined into a key1=value1;key2=value2; type of string. I started out by putting the data in a KeyValuePair<string,string>, but now I am wondering if that should be it's own class instead.

Overall, I am interested in finding out what guidelines are used when deciding to use an existing structure/class like a KeyValuePair over a 2-property object, and in what kind of situations you would use one over another.

答:
S.Lott wrote

Do not introduce new classes without a good reason. Or use pre-built
  classes as much as possible. Invent as little as possible.

You cannot use a pre-built class if you have to assign some unique
  responsibility to the object that is not defined in the pre-built
  class.

Let me say why I have a serious issue with this. Since

KeyValuePair [string,string]

seems to be okay .... is KeyValue [string, KeyValue [string, KeyValuePair [string, string]]] also okay ? I don't know what S.Lott will say to this, but my boss thinks it is okay.

I dare to disagree. And here's why : It reduces Readability of the code that will follow. The function that will fill up such a data structure will be much more complex and error (err .. exception) prone (just imagine at least some business logic as well). I didn't argue with my boss too much, but i will say it here : Readability trumps minute space savings (which was his argument). So wouldn't a class object in which there are some fields ; but some remain empty at some times be better ?

P.S. I am an Ultra_Noob so please tell me if I am wrong.


答:
Take as long as you need so that you select enough that your team thinks they can reasonably achieve in the sprint. But you should be spending time during the (previous) sprint refining the backlog: estimating and refining stories.

From the Scrum Primer (PDF):

Product Backlog Refinement

One of the lesser known, but valuable, guidelines in Scrum is that
  five or ten percent of each Sprint must be dedicated by the Team to
  refining (or “grooming”) the Product Backlog. This includes detailed
  requirements analysis, splitting large items into smaller ones,
  estimation of new items, and re-estimation of existing items. Scrum is
  silent on how this work is done, but a frequently used technique is a
  focused workshop near the end of the Sprint, so that the Team and
  Product Owner can dedicate themselves to this work without
  interruption. For a two-week Sprint, five percent of the duration
  implies that each Sprint there is a half-day Product Backlog
  Refinement workshop. This refinement activity is not for items
  selected for the current Sprint; it is for items for the future, most
  likely in the next one or two Sprints. With this practice, Sprint
  Planning becomes relatively simple because the Product Owner and Scrum
  Team start the planning with a clear, well-analyzed and carefully
  estimated set of items. A sign that this refinement workshop is not
  being done (or not being done well) is that Sprint Planning involves
  significant questions, discovery, or confusion and feels incomplete;
  planning work then often spills over into the Sprint itself, which is
  typically not desirable.

Doing this means you can focus on planning during planning, and it doesn't take all day and the team starts to lose focus and get bored.


答:
EDIT: Turns out that I am wrong. Nevertheless, maybe this helps someone keep their symbols straight, so I'm not going to delete it.

Actually, it's not the Latin letter Oh, it's the Greek letter Omicron. Unfortunately, those two have the exact same glyph, so, over time, the original version got corrupted, and now it is just Oh.

The choice of symbol doesn't actually have any particular meaning, it was chosen as a mnemonic device:

Omicron has the letters M-I-C-R-O in it, and the semantics of the Omicron symbol roughly mean "smaller than"

Omega has the letters M-E-G-A in it, and the semantics of the Omega symbol roughly mean "bigger than"

Theta (Θ) looks a bit like an equals sign, and the semantics of the Theta symbol roughly mean "equal to"

That's it. There's no real meaning to it, it's just a play on words, if you will, to help you remember the semantics more easily.

Title: What is O in Big O?