答:
Why?

JavaScript the most misunderstood language

We were in the dark ages and still are for the general development community to accept that JavaScript is a powerful and versatile language. It's simply not mainstream.

The only recent advance is that node.js has become buzz-wordy and people are starting to accept that javascript has other uses..

I've been keeping an eye on the JS & HTML5 development for windows 8 and the reaction from the .NET community was "dear god why?".

It's simply fact that most non-web developers still see JavaScript as that toy language you use to make those scroll over menus in your browsers.

Admittedly JavaScript doesn't align with "modern development practices". For me JavaScript is still a hacking language I crack out with vim & the internet is my documentation. There is no IDE, there are no development tools, there is no auto-complete or "intellisense", there are no click and drag GUIs.

In the world of Java and .NET developers they are wedded to their GUIs & IDEs and would not be able to program in vim.

Title: Why is JavaScript not used for classical application development (compiled software)?

Body:
During my years of web development with JavaScript, I come to the conclusion that it's an incredible powerful language, and you can do amazing things with it.

It offers a rich set of features, like:

Dynamic typing

First-class functions

Nested functions

Closures

Functions as methods

Functions as Object constructors

Prototype-based

Objects-based (almost everything is an object)

Regex

Array and Object literals

It seems to me that almost everything can be achieved with this kind of language, you can also emulate OO programming, since it provides great freedom and many different coding styles.

With more software-oriented custom functionalities (I/O, FileSystem, Input devices, etc.) I think it will be great to develop applications with.

Though, as far as I know, it's only used in web development or in existing softwares as a scripting language only.

Only recently, maybe thanks to the V8 Engine, it's been used more for other kind of tasks (see node.js for example).

Why until now it's only be relegated only to web development? What is keeping it away from software development?


问:
Why is JavaScript not used for classical application development (compiled software)?
During my years of web development with JavaScript, I come to the conclusion that it's an incredible powerful language, and you can do amazing things with it.

It offers a rich set of features, like:

Dynamic typing

First-class functions

Nested functions

Closures

Functions as methods

Functions as Object constructors

Prototype-based

Objects-based (almost everything is an object)

Regex

Array and Object literals

It seems to me that almost everything can be achieved with this kind of language, you can also emulate OO programming, since it provides great freedom and many different coding styles.

With more software-oriented custom functionalities (I/O, FileSystem, Input devices, etc.) I think it will be great to develop applications with.

Though, as far as I know, it's only used in web development or in existing softwares as a scripting language only.

Only recently, maybe thanks to the V8 Engine, it's been used more for other kind of tasks (see node.js for example).

Why until now it's only be relegated only to web development? What is keeping it away from software development?

答:
Your list does not contain anything about writing files to the system, which is a massive part of software development.

People would not think of using JS to build an application because it the de facto scripting language for web, and you would always use the right tool for the job.

Why write acres of JS to write out a file when it is a trivial operation in Java/.NET/C/C++?

With that said, as others have mentioned, node.js and its libraries have made server side operations trivial and with node.js becoming popular, learning it will become a skill for a CV, since you will be able to maintain/extend/build applications with it.

ContentLicense: CC BY-SA 3.0


问:
Single Line Statements & Good Practices
I have recently acquired a habit which I know many of you may frown upon, but which, in the end, helps me keeping an eye on global code structure rather than on the structure of a single, (sometimes) repetitive method: grouping a number of statements in a single line, like this:

textBox1.Text = "Something!"; textBox2.Text = "Another thing!"; textBox3.Text = "Yet another thing!";
```

<p>as opposed to</p>

<pre class="lang-cs prettyprint-override"><code>textBox1.Text = "Something!";
textBox2.Text = "Another thing!";
textBox3.Text = "Yet another thing!";
</code>```

I use to do that for repetitive tasks to maintain overall code "beauty" and to help me tracking program structure easily, but I admit it may not be a good practice. I actually use it a lot, so I would like to know what are your thoughts on this. Also, do you think that anyone which would ever have to maintain my code have problems with this approach?

答:
Also, do you think that anyone which would ever have to maintain my
  code have problems with this approach?

After putting his hands on his head for a minute, he will use its favorite IDE Regex functionalities to automatically separate all that unreadable code into one statement per line.

Just a quick look at the example you showed is enough to understand how much more readable is the second approach.

It's much easier to follow the vertical page flow, without having your eyes to move horizontally forever.

Look at your example: you immediately know the code is all about the Text property of different textBox objects, and they contain string as values. Pretty straightforward.

OwnerDisplayName: User

Title: Single Line Statements & Good Practices


问:
What comes first, the ruby chicken or the homebrew egg?
Whilst installing Ruby on OsX I noticed I could do so by using a package manager called Homebrew. This seemed like an easy option, so I took it. Everything worked smoothly. Life was good.

Being a curious fellow, I looked into what other benefits having homebrew installed would give me, and in my study found that Homebrew is written in ruby.

Woah, wait a minute! How is it then, that I can install Ruby using something that is written in Ruby, not already having Ruby on my system, and once installed said ruby based system I STILL have to install ruby separetely?

Warning: Do not read this question aloud. You risk getting a Kaiser Chiefs single stuck in your head for the remainder of the day.

答:
OS X comes pre bundled with system ruby. If you typed which -a ruby I'm pretty sure you'd get at least 3 results: system, homebrew and linked-to-homebrew.

It is also possible that homebrew installation is written in sh which in turn downloads and compiles ruby for itself.

update

Just do ln -h /usr/bin/ruby. It should tell you that it's symlink from system folder.


问:
What determines when a computer is considered a "client"?
In web development the terms "server" and "client" are often refered to when discussing how pages are requested on the web. It is also used exstensively when talking about PC, phone, tablets, etc. The question that came to my mind was what qualified a computer to be considered a client?

I took a look at this article from wikipedia and noticed that clients are considered service requesters whereas Servers are considered service providers. If this is true couldn't all computers that request a service in a sense be considered a client?

The stereotype I noticed is that a client computer is usually synonymous with a "consumer" computer, but according to wikipedia this is not entirely accurate. Any idea on how to draw the line in this common scenario?

答:
A computer cannot be determined as a server or a client. If the computer hosts a server application then you can call it a server. But some of computer's applications maybe alwasys acts as a client (requesting pages).

It's not the computer. But it's the applications that distinguishes client and server.


问:
Choosing the type of Index Variables
We use Integer type represent index variables most of the time. But in some situations, we're forced to choose

```<code>std::vector<int> vec;
....

for(int i = 0; i < vec.size(); ++i)
....
</code>```

This will cause the compiler to raise the warning that mixed use of signed/unsigned variables. if I make the index variable as for( size_t i = 0; i < vec.size(); i++ ), (or an unsigned int )it will sort out the issues.

When it come more specific to use windows types, most of the Windows APIs are dealing with DWORD (which typedef-ed as unsigned long).

So when I use similar iteration, will again cause the same warning. Now if I rewrite it as

```<code>DWORD dwCount;
....

for(DWORD i = 0; i < dwCount; ++i)
....
</code>```

I find this a bit weird. It might be the problem withe perceptions.

I agree that we are supposed to use the same type of index variable to avoid the range problems can happen with the index variables. For e.g if we're using

```<code>_int64 i64Count; //
....

for(_int64 i = 0; i < i64Count; ++i)
....
</code>```

But in the case of DWORD, or unsigned integers, are there any problems in rewriting it as

```<code>for(int i = 0; (size_t)i < vec.size(); ++i)
</code>```

How most of the people are working with similar issues?

答:
vector has a typedef that tells you the correct type to use :-

```<code>for(std::vector<int>::size_type i = 0; i < thing.size(); ++i)
{
}
</code>```

It's almost always defined to be size_t though but you can't rely on that

Title: Choosing the type of Index Variables

Body:
vector has a typedef that tells you the correct type to use :-

for(std::vector<int>::size_type i = 0; i < thing.size(); ++i)
{
}

It's almost always defined to be size_t though but you can't rely on that


问:
UnitTests, will cleaning up your act-statement make your test more or less clear?
Lets say that we are testing FooClass with the following method:

```<code>    public void Foo(string stringParameter, int intParameter, Action<Bar> successCallback, Action<Exception> errorCallback);
</code>```

If the call to Foo succeeds, the successCallback will be called with the result of Foo in the form of a Bar object. If it fails, the errorCallback will be called with an Exception.

So the tests will look something like this:

```<code>[TestMethod]
public void Foo_UnderGivenConditions_WeExpectAGivenResult()
{
    //Arrange
    var fooObject = CreateFooObjectWithGivenConditions( ... );

    //Act
    fooObject.Foo(String.Empty, 0, (bar) => { ... }, (error) => { ... });

    //Assert
    Assert.AreEqual(..., ...);
}
</code>```

Now, there are a lot of tests on this Foo-method, all of them containing a call to Foo, but not every test will care for all the parameters. Some may provide different string values, but doesn't care about the int param, and some will need to provide an error callback to assert that the right exception is thrown and so on.

Now, since all the parameters are mandatory, we have to pass a string value to the Foo method, even though the value has no meaning for the test. There will be a lot of "I don't care" or "some text". When some one else comes and read the test, they have to consider if the given value actually has a meaning for the test result or not. The same goes for the callbacks. Sometimes we need the callbacks to get to the result value or the exception, but most of the time we do not.

So lets implement an extension method, PerformFoo, that defaults every parameter:

```<code>public static Bar PerformBar(this FooClass fooObject, string stringParameter = "some text", int intParameter = 0, Action<Bar> successCallback = null, Action<Exception> errorCallback = null);
{
   Bar result = null;

   var ourCallback = (bar) =>
      {
          result = bar;
          if (successCallback != null)
              sucessCallback.invoke();
      }

   fooObject.Foo(stringParameter, intParameter, ourCallback, errorCallback);

   return result;
}
</code>```

The extension method will call Foo with default parameters, and even return the result if the successCallback is called. This lets us change the Act part of the test to something like:

```<code>//Act, all we care about is the string parameter:
fooObject.PerformFoo("A string that we care about");

//Act, we need the resulting bar when the int parameter is 10:
var bar = fooObject.PerformFoo(intParameter: 10);

//Act, we still needs to provide a callback to get the exception
fooObject.PerformFoo("SomeInvalidValueCausingAnException", errorCallback: (error) => { exceptionThrown = error; });
</code>```

So the questions would be:

Does this make the tests more readable?

Is it easier to get what the test really tests?

The fact that we call PerformFoo, which doesn't really exist on the class under test make the test less worth as an documentation?

Would dropping the extension method for a regular method taking the fooObject as the first parameter be less of a 'lie'? (e.g. PerformFoo(fooObject, intParameter: 10) )

How far would you go to make your tests clean and clear?

答:
Not sure if using the callbacks for exception assertion is any better then [ExpectedException] attribute.

For a test code, it's not any different from any other code in that you want it to be clear.

In my tests, I usually apply programming principles to the test code which i find productive without hesitation.

Composition is a powerful tool to form ubiquitous language specific to the domain model, but to my taste, your PerformBar method is too general. I usually end up with more specialized composition methods.

```<code>public class RandomQueueGeneratesSequence
{
 private IEnumerable<T> ActualResult<T>(IEnumerable<T> source, int seed)
 {
  // Setup
  var q = new RandomQueue(new Random(seed));

  // Act
  foreach(var i in source)
    q.Add(i);
  var l = new List<T>();
  while( q.HasItems )
  {
   l.Add(q.GetItem());
  }
  return l;
 }
 [Test, Combinatorial]
 public void ContainingAllSourceItems([Values(0,1,12345)] int seed)
 {
  CollectionAssert.AreEqualent(new[]{1,2,3}, ActualResult(new[]{1,2,3},seed));
 }
 [Test, Combinatorial]
 public void WithSingleItem([Values(0,1)] expectedValue, [Values(0,1,12345)] int seed)
 {
  Assert.AreEqual(expectedValue, ActualResult(new[]{expectedValue}, seed).Single());
 }
 [Test]
 public void InOrderBySeed1()
 {
  CollectionAssert.AreEqual(new[]{1,2}, ActualResult(new[]{1,2}, 123));
 }
 [Test]
 public void InOrderBySeed2()
 {
  CollectionAssert.AreEqual(new[]{2,1}, ActualResult(new[]{1,2}, 456));
 }
}
</code>```

In this example, it's not reasonable to compose the asserting methods, because different ones are used (Assert.AreEqual, CollectionAssert.AreEqual, CollectionAssert.AreEqualent).

But if there's more then two tests follow some pattern, found in InOrderBySeed, move an assert to a composing method, and name it an Assert:

```<code> protected void AssertInOrder<T>(IEnumerable<T> expected, IEnumerable<T> source, int seed)
 {
  CollectionAssert.AreEqual(expected, ActualResult(source, seed));
 }

 public void InOrderBySeed1()
 {
  AssertInOrder(new[]{1,2}, new {1,2}, 123);
 }
 [Test]
 public void InOrderBySeed2()
 {
  AssertInOrder(new[]{2,1}, new[]{1,2}, 456);
 }
 [Test]
 public void InOrderBySeed3()
 {
  AssertInOrder(new[]{3,1,2}, new[]{1,2,3}, 789);
 }
</code>```

Generally, when your test code becomes clear enough, you will find yourself not needing comments anymore. Especially when the intent is clear from a method name. In this example - Assert prefix obsoletes the // Assert comment.

Body:
Not sure if using the callbacks for exception assertion is any better then [ExpectedException] attribute.

For a test code, it's not any different from any other code in that you want it to be clear.

In my tests, I usually apply programming principles to the test code which i find productive without hesitation.

Composition is a powerful tool to form ubiquitous language specific to the domain model, but to my taste, your PerformBar method is too general. I usually end up with more specialized composition methods.

public class RandomQueueGeneratesSequence
{
 private IEnumerable<T> ActualResult<T>(IEnumerable<T> source, int seed)
 {
  // Setup
  var q = new RandomQueue(new Random(seed));

  // Act
  foreach(var i in source)
    q.Add(i);
  var l = new List<T>();
  while( q.HasItems )
  {
   l.Add(q.GetItem());
  }
  return l;
 }
 [Test, Combinatorial]
 public void ContainingAllSourceItems([Values(0,1,12345)] int seed)
 {
  CollectionAssert.AreEqualent(new[]{1,2,3}, ActualResult(new[]{1,2,3},seed));
 }
 [Test, Combinatorial]
 public void WithSingleItem([Values(0,1)] expectedValue, [Values(0,1,12345)] int seed)
 {
  Assert.AreEqual(expectedValue, ActualResult(new[]{expectedValue}, seed).Single());
 }
 [Test]
 public void InOrderBySeed1()
 {
  CollectionAssert.AreEqual(new[]{1,2}, ActualResult(new[]{1,2}, 123));
 }
 [Test]
 public void InOrderBySeed2()
 {
  CollectionAssert.AreEqual(new[]{2,1}, ActualResult(new[]{1,2}, 456));
 }
}

In this example, it's not reasonable to compose the asserting methods, because different ones are used (Assert.AreEqual, CollectionAssert.AreEqual, CollectionAssert.AreEqualent).

But if there's more then two tests follow some pattern, found in InOrderBySeed, move an assert to a composing method, and name it an Assert:

 protected void AssertInOrder<T>(IEnumerable<T> expected, IEnumerable<T> source, int seed)
 {
  CollectionAssert.AreEqual(expected, ActualResult(source, seed));
 }

 public void InOrderBySeed1()
 {
  AssertInOrder(new[]{1,2}, new {1,2}, 123);
 }
 [Test]
 public void InOrderBySeed2()
 {
  AssertInOrder(new[]{2,1}, new[]{1,2}, 456);
 }
 [Test]
 public void InOrderBySeed3()
 {
  AssertInOrder(new[]{3,1,2}, new[]{1,2,3}, 789);
 }

Generally, when your test code becomes clear enough, you will find yourself not needing comments anymore. Especially when the intent is clear from a method name. In this example - Assert prefix obsoletes the // Assert comment.


问:
Should the domain model  include all the domain entities in my project?
I have currently reading Grails and I love it. In order to get hands on experience with Grails I decided to create a web application for some Management System. Ya as you can guess there are plenty of entities that goes into the domain model for my web application. Any how as a novice in Web development, I just thought of creating a homepage first of all.

Now here comes the problem, I sat for an hour and drawn my domain model(for my homepage alone!). After that I had a doubt that whether we have to enter all the entities(i.e my whole web app entities like user, profile, tasks and their relationships etc) in Domain model first and then start coding or draw domain models for each page in our web app and at last connect all the domain models?

Well, what I do is wrong? This is my first project that ever started in my life.
Thanks for your advices.

答:
A domain model appears in several phases, analysis, design and implementation. From your question, I think that you're talking about including all of your classes (domain model in implementation phase) into your home page.

For example, I think that you want to instantiate all classes, and then use them. Well, then answer is, it depends on your requirements. Consider YouTube for example. In its home page, it needs to deal with tens of entities. Movies, Comments, Users, Subscriptions, Ads, etc. Of course they need to include and instantiate all of these classes while they're building their home page.

However, if your home page is only a welcome page with some news in it, and for it you don't need to do anything with user, authentication, advertisement, etc. then you shouldn't include your whole domain, while you're developing your home page.


问:
Infinite Bitmap
I'd like to build a bitmap during runtime. The bitmap should be scalable on all sides and pixel access should be quiet efficient.

Some illustration http://img546.imageshack.us/img546/4995/maptm.jpg

Between and after the commands shown in the picture, Map.setPixel() and Map.getPixel() should set/return data saved in the bitmap.

I don't expect an implementation just a concept how to allocate memory in such a way that the setPixel()/getPixel is as fast as possible.

答:
The absolute fastest way to do pixel access is a two-dimensional array of individually-addressable pixels.

For extensions, start with a simple implementation that reallocates and copies every time (since you'll need that code anyway).  If profiling doesn't indicate that you're spending a lot of time at it, there's no need to refine it further.

If profiling reveals a need to keep the number of re-allocations down and you're not memory-constrained, consider over-allocating by a percentage in each direction and storing an offset to the origin. (E.g., if you start a new bitmap at 1x1 and allocate a 9x9 array to hold it, the initial x and y offsets would be 4.)  The trade-off here is having to do extra math during pixel access to apply the offset.

If extensions turn out to be really expensive, you could try one or both of these:

Handle vertical and horizontal extensions differently.  Extending an array vertically in any direction can be accomplished by allocating a new block and doing a single copy of the entire existing array to the appropriate offset in the new memory.  Compare that to horizontal extensions, where you have to do that operation once per row because the existing data isn't contiguous in the new block.

Keep track of the most frequent amount and direction of extension.  Use that information to select a new size and offset which will reduce the probability of having to do a re-allocate-and-copy for any extension.

Personally, I doubt you're going to need either of those unless the pixel-access-to-extension ratio is low.

Title: Infinite Bitmap


问:
What are some good criteria for using Tracer Bullets?
I was recently reading The Pragmatic Programmer for the first time and I came across the concept of Tracer Bullets.  I realized that I had coded according to this model in the past and just kind of filed the way I was working away in my brain as "agile".

They only give one example of where they had used it in the past.  The way the situation was identified to be a good candidate for Tracer Bullets was

There were many unknowns, and many different environments, and no one was too sure how the GUI should behave.

That kind of seems like the way a huge number of projects start, especially when you're working with non-technical people on a typical line of business app for a hedge fund (as an example).

I used it because it simply felt right, without really knowing what it was called or having it explained to me.  I knew that if I tried to get everyone in a room and got them to spec everything (or at least some things) up front it would be a complete disaster, but again that's a feel kind of thing...

Can anyone come up with some more concrete criteria for when this model might be the way to go?

答:
You need to have a project where you can get an idea about if you're on the right track with only a small subset of functionality. Generally this is possible for things like basic GUI design, but is hard with things where the results are unknown -- e.g. if you are designing a data mining app and the shape of the tool will depend on what sort of patterns occur in your data.

You also need to be in a situation where you can afford to iterate many times. This costs time and development (and of course may be beneficial if you subscribe to agile development processes), but more difficult is the cost in terms of exposure to users. Users will quickly get exhausted if you show them too many designs and the quality of your feedback will go way down. So you either need a large user pool, or to pick your (micro)releases carefully.

OwnerDisplayName: Jason Punyon

ContentLicense: CC BY-SA 2.5

OwnerDisplayName: Alex Feinman


答:
The case you described is one of the things I dislike in C++, too. But I have learned to live with that, either by using

for( size_t i = 0; i < vec.size(); i++ )

or

for( int i = 0; i < (int)vec.size(); i++ )

(of course, the latter only when there is no risk of getting some int overflow).

Title: Choosing the type of Index Variables

Body:
We use Integer type represent index variables most of the time. But in some situations, we're forced to choose

```<code>std::vector<int> vec;
....

for(int i = 0; i < vec.size(); ++i)
....
</code>```

This will cause the compiler to raise the warning that mixed use of signed/unsigned variables. if I make the index variable as for( size_t i = 0; i < vec.size(); i++ ), (or an unsigned int )it will sort out the issues.

When it come more specific to use windows types, most of the Windows APIs are dealing with DWORD (which typedef-ed as unsigned long).

So when I use similar iteration, will again cause the same warning. Now if I rewrite it as

```<code>DWORD dwCount;
....

for(DWORD i = 0; i < dwCount; ++i)
....
</code>```

I find this a bit weird. It might be the problem withe perceptions.

I agree that we are supposed to use the same type of index variable to avoid the range problems can happen with the index variables. For e.g if we're using

```<code>_int64 i64Count; //
....

for(_int64 i = 0; i < i64Count; ++i)
....
</code>```

But in the case of DWORD, or unsigned integers, are there any problems in rewriting it as

```<code>for(int i = 0; (size_t)i < vec.size(); ++i)
</code>```

How most of the people are working with similar issues?


问:
Scrum roles mixed up
Here at the office our Scrum roles are a bit mixed up, so I would appreciate any advice on how to improve it.

We are a small team of 4 developers (one of which is a de facto scrum master) and we also have a line manager and a Product Owner. The line manager simultaneously embraces Scrum and has a hard time "letting go"; he has the Product Backlog in his head and also prioritizes it.

A previous attempt to take it out of his head only lead to a short lived up-to-date Product Backlog in Pivotaltracker.com – politically speaking he was the programmer who built the current  system 7 years ago. The Product Owner has been in the company for about 2 years and seems to have a clear vision of the product, but he is underpowered by our line manager (who in fact is held responsible for this and other projects). Other than this, our implementation of Scrum is “by the book”.

What do you think are disadvantages of this structure we find ourselves into? What could be improved? How would you improve?

答:
The line manager simultaneously embraces Scrum and has a hard time "letting go"; he has the Product Backlog in his head and also prioritizes it.

I'm assuming that your line manager is filling the role of Scrum Master. In this example, he's not embracing traditional Scrum roles.

One of the key aspects of any agile methodology is high visibility. That means that the work products are visible to the customer on a regular basis (as seen through frequent releases of potentially-shippable products), but also that internal status and metrics are visible to the team. The product backlog and it's current state should not be in anyone's head, but visible to the entire team (and some would even argue to the customer as well, if they desire it).

Also, the Product Owner is supposed to be the owner of the Product Backlog. It's the job of the Product Owner to write user stories, prioritize those stories in the Product Backlog, and ensure that stories are properly completed (verified and validated).

The Product Owner has been in the company for about 2 years and seems to have a clear vision of the product, but he is underpowered by our line manager (who in fact is held responsible for this and other projects).

Your Product Owner needs to have the ability to speak for the customer, otherwise, this role is pointless. Having a clear vision is important, but if he can't act on this vision and create and prioritize stories in order to allow software to achieve maximal value, then he can't fulfill the responsibilities of the Product Owner.

What do you think are disadvantages of this structure we find ourselves into? What could be improved? How would you improve?

The disdvantages are that you aren't utilizing your people. It's pointless to have a visionary or champion if they can't do anything to act on their visions or goals. It all comes back to the bottom line - what are you paying these people to do and are they able to do it? It sounds like they aren't able to fulfill their responsibilities, so something needs to be fixed.

The only way to improve is to reevaluate roles and make sure everyone knows their responsibilities to the project and product. You should also focus on product and process quality rather than following a process to-the-letter. Perhaps by-the-book Scrum isn't what you need, so tailor the process to fit how your team and organization works.

Other than this, our implementation of Scrum is “by the book”.

Following up on my last thought, any "by-the-book" process implementations worry me. Scrum is a framework for project management. There are concrete implementation described, and success stories, but those are for particular teams within particular organizations working on particular projects. Scrum is a perfectly fine framework, as long as you tailor it to meet the needs of your team within your organization working on your project.

Title: Scrum roles mixed up


问:
What are advantages and disadvantages of browser rapid release cycles for web developers?
Chrome and Firefox have now rapid release cycles. Also Opera is starting to get speed and Internet Explorer should take the high road soon. I am a web developer. What does that mean for me? What consequences does it have for me? Will it be an advantage for my work or another burden?</p>

答:
After the super buggy first release of FF4, I hope they will be able to keep up with the fast release dates, trying to release something which actually work and don't break existing websites.

To me, fastest release dates means more worries for us developers about new possible bugs and breaking existing websites, and nothing better at all.

I would prefer a full latest-standard compliant browser once in 10 years and nothing more, if you ask me.

OwnerDisplayName: tomaszs


答:
It doesn't sound to me like you have your Scrum roles mixed up. It sounds like you have one individual who is unsure what his role is and is nullifying someone else's role in the process of trying to demonstrate his continued worth.

Sit down, as a team, and figure out what you need from your team leader. Do you need him to be a technical guru? Or a domain guru? Or do you need someone who will be a "bottleneck ninja," removing every problem that slows down the development team? Or if you need none of these, as a fully mature Agile team, do you need to reintegrate him back into development?

Involve him in this conversation. See what he wants from the situation. It might be that he'd prefer to get back to development. It might be that he's filling the role of Product Owner because he doesn't feel that the current PO is good enough.

Honest communication is always key in these situations.

Title: Scrum roles mixed up

Body:
Here at the office our Scrum roles are a bit mixed up, so I would appreciate any advice on how to improve it.

We are a small team of 4 developers (one of which is a de facto scrum master) and we also have a line manager and a Product Owner. The line manager simultaneously embraces Scrum and has a hard time "letting go"; he has the Product Backlog in his head and also prioritizes it.

A previous attempt to take it out of his head only lead to a short lived up-to-date Product Backlog in Pivotaltracker.com – politically speaking he was the programmer who built the current  system 7 years ago. The Product Owner has been in the company for about 2 years and seems to have a clear vision of the product, but he is underpowered by our line manager (who in fact is held responsible for this and other projects). Other than this, our implementation of Scrum is “by the book”.

What do you think are disadvantages of this structure we find ourselves into? What could be improved? How would you improve?


问:
How to get better at testing your own code
I am a relatively new software developer, and one of the things I think I should improve is my ability to test my own code. Whenever I develop a new functionality, I find it really difficult to follow all the possible paths so I can find bugs. I tend to follow the path where everything works. I know this is a well known issue that programmers have, but we don't have testers at my current employer and my colleagues seem to be pretty good at this.

At my organization, we do neither test-driven development nor unit testing. It would help me a lot but it's not likely that this will change.

What do you guys think I could do in order to overcome this? What approach do you use when testing your own code?

答:
In my experience

Test unit, if it is not completely automatic,it is useless. It is more like a  Pointy Haired Boss could buy. Why?, because Test Unit promised you to save time (and money) automating some test process. But, some test unit tools do the opposite, it force programmers to work in some weird fashion and force other to create over-extend test. Most of the time, it will not save working hour but increase moving time from QA to developer.

UML is another time waster. a single whiteboard + pen could do the same, cheaper and quickly.

BTW,How to be good at coding (and avoid bugs) ?

a) atomicity.  One function that do one simple (or a few single task).  Because it is easy to understand, it is easy to track and it is easy to solve it.

b) Homology. If, for example, you call a database using a store procedure then do for the rest of the code.

c) Identify,reduce and isolate "creative code". Most of the code is pretty much copy & paste. Creative code is the opposite, a code that is new and it act as a prototype, it can fail. This code is prone of logic bug, so it is important to reduce, isolate and identify it.

d) "Thin ice" code, is the code that you know that it is "incorrect" (or potentially dangerous) but still is needing, for example unsafe code for a multi task process.  Avoid if you can.

e) Avoid black box code, this include code that it is not done by you (for example framework) and expression regular. It is easy to miss a bug with this kind of code. For example, i worked in a project using Jboss and i found not one but 10 error in Jboss (using the latest stable version), it was a PITA to find those.   Avoid specially Hibernate, it hide the implementation, hence the bugs.

f) add comments in your code.

g) user input as source of bugs. identify it. For example, SQL Injection is caused by a user input.

h) Identify bad element of the team and separate the task assigned.   Some programmers are prone to screw the code.

i) Avoid unnecesary code. If, for example, the class need Interface then use it, otherwise avoid to add irrelevant code.

a) and b) are key.  For example, i had a problem with a system, when i clicked in a button (save) it didn't save the form.  Then i did a checklist:

the button works?... yes.

the database store something?.  no, so the error was in a middle step.

then, the class that store in the database work?. no <-- ok, i found the error. (it was related with database permission).  Then i checked not only this procedure but every procedure that do the same (because the homology of the code).  It took me 5 minutes to track the bug and 1 minute to solve it (and many other bugs).

And a sidenote

Most of the time QA suck (as a separate section of Dev), it is useless if they are not worked in the project. They do some generic test and nothing else much. They are unable to identify most logic bugs. In my case, i was working in a prestigious bank, a programmer finished a code then send it to QA. QA approved the code and was put in production... then the code failed (an epic fail), do you know who was blamed?. yes, the programmer.


问:
How do you prevent the piracy of your software?
Is it still worth it to protect our software against piracy? Are there reasonably effective ways to prevent or at least make piracy difficult?</p>

答:
Hmmm, only two solutions:

1) Release under GPL (or similar)

2) SaaS


答:
The reason it's warning you about comparison between signed and unsigned is because the signed value will likely be converted to unsigned, which might not be what you expect.

In your example (comparing int to size_t), int will be implicitly converted to size_t (unless int somehow has a larger range than size_t).  Thus, if the int is negative, it will likely be greater than the value you're comparing it to due to wraparound.  This won't be a problem if your index is never negative, but you'll still get that warning.

Instead, use an unsigned type (such as unsigned int, size_t, or, as John B recommends, std::vector<int>::size_type) for your index variable:

```<code>for(unsigned int i = 0; i < vec.size(); i++)
</code>```

Be careful when counting down, though:

```<code>for(unsigned int i = vec.size()-1; i >= 0; i--) // don't do this!
</code>```

The above will not work because i >= 0 is always true when i is unsigned.  Instead, use the "arrow operator" for loops that count down:

```<code>for (unsigned int i = vec.size(); i-- > 0; )
    vec[i] = ...;
</code>```

As other answers point out, you normally want to use an iterator to traverse a vector.  Here's the C++11 syntax:

```<code>for (auto i = vec.begin(); i != vec.end(); ++i)
</code>```

Title: Choosing the type of Index Variables

Body:
The reason it's warning you about comparison between signed and unsigned is because the signed value will likely be converted to unsigned, which might not be what you expect.

In your example (comparing int to size_t), int will be implicitly converted to size_t (unless int somehow has a larger range than size_t).  Thus, if the int is negative, it will likely be greater than the value you're comparing it to due to wraparound.  This won't be a problem if your index is never negative, but you'll still get that warning.

Instead, use an unsigned type (such as unsigned int, size_t, or, as John B recommends, std::vector<int>::size_type) for your index variable:

for(unsigned int i = 0; i < vec.size(); i++)

Be careful when counting down, though:

for(unsigned int i = vec.size()-1; i >= 0; i--) // don't do this!

The above will not work because i >= 0 is always true when i is unsigned.  Instead, use the "arrow operator" for loops that count down:

for (unsigned int i = vec.size(); i-- > 0; )
    vec[i] = ...;

As other answers point out, you normally want to use an iterator to traverse a vector.  Here's the C++11 syntax:

for (auto i = vec.begin(); i != vec.end(); ++i)


问:
What could be a good team building activity to improve estimation skills?
I'm putting together a presentation to deliver to some of my teammates (all developers), and I'd like to include a short team building activity that focuses on improving estimation skills. Does anyone have any suggestions or know of any team building activities I could use?</p>

答:
Check out Joel On Software's Evidence Based Scheduling, it's a fairly simple way for people to figure out how estimate more accurately.

The best way to learn how to estimate is to have good requirements, practice, practice, and practice. Teaching them things like Evidence Based Scheduling will help the practice be more effective, but nothing can replace actual practicing.


答:
I suggest a labyrinth generator/solver for the following points :

It is fun to do

You can't think of all the cases for the first time

The generation and solving stuff are quite complementary

This covers from back-end with data saving to front-end with data loading

Many points can be assigned to people : file specification, display, generation, solving, optimization, testing etc...

Title: What could be a good team building activity to improve estimation skills?

Body: I'm putting together a presentation to deliver to some of my teammates (all developers), and I'd like to include a short team building activity that focuses on improving estimation skills. Does anyone have any suggestions or know of any team building activities I could use?</p>


答:
@Thomas Owens has identified your problems and given solutions, but I'd like to add a few more suggestions.

The 4 team members need to commit to PivotTracker or whatever you prefer. If the line manager wants everthing in his head, that's his perogotive, but the rest of you need to put it in writing. I sit in a lot of meetings and force managers to slow down because I'm taking notes. Take responsibility as a team to getting organized.

The Product Owner has to be able to stand up for clients and not let the technologists take advantage because they know more about programming. The Product Owner may not know as much about the clients as your line manager. That's a shame and an indication they cannot do their job and someone else is picking up the slack. There are situations where someone built the application and maybe had a lot of contact with clients/users and is oppertating with outdated information and assumptions. Seven years ago, most users weren't interested in a Facebook interface. Times have changed. Your team may need to make an effort to get the client's needs from the Project Owner if he/she is being over-shadowed by the line manager for the wrong reasons.

Stakeholders complain less when you are taking care of their clients. Make that a priortity and work around your disfunctional leaders.

Title: Scrum roles mixed up


问:
How do you answer the question, "where do you see yourself in 5 years?"
What do recruiters expect you to answer when they ask, "Where do you see yourself in 5 years?" Something like:

I want to improve my technical skills ... blah-blah-blah ... architect?

Is it just to check your ambitions and if you are not going to leave in a month?

答:
I answer truthfully, which in my case usually amounts to something like: Ideally I'd like to be either a Systems/Business Analyst and focus entirely on high-level problem solving instead of low-level coding implementations, or in some kind of Team Lead/Manager/Supervisor role where I can focus on architecture and problem solving.  While my development skills are fairly good, I get more enjoyment out of planning out abstractions and solutions to problems than doing the actual coding.

To go on a bit of a rant though, I find this to be a loaded question.  Chances are if you answer truthfully, as I have, you won't get the job because the company doesn't really care about your goals, they want to know that you will work towards their goals.  Saying you want to be a manager in five years is the nail in the coffin if the person you are interviewing with is the manager; saying you want to move towards being a team lead is shooting yourself in the foot if the company doesn't have a team lead or if the team lead has been there for 10+ years.

It's been my experience the expected answer is some polite variation of "Slaving away for the company at the same position for a minuscule raise, if I'm lucky".  The question is often designed to make sure you don't have any ambition, not the other way around.


答:
Present an example problem using Minecraft.

The customer needs a brown step pyramid that is 20x20 blocks.  The pyramid also needs a moat that is at least 10 blocks wide.

Give them 3 minutes to sketch up a simple WBS and an estimate.

2 minutes in, say that the customer changed their mind and they need a 30x30 pyramid now.  Tell them to revise their estimates in the remaining minute.

At the end of the time tell them to put their pencils down, and now say that the developers start working on the project but the client is confused because there wasn't a bridge going across the moat.

Tell them that the bridge would take X hours to develop and ask for everybody who underestimated to stand up.

This will drive the point home.


答:
```<code>//Act, we need the resulting bar when the int parameter is 10:
var bar = fooObject.PerformFoo(intParameter: 10);
</code>```

As a developer coming across this unit test, it'd take me a few seconds to get beyond that "proxy" method and figure out which behavior of the class under test is actually tested, as there is no direct mention of the original method. So I wouldn't say it is more readable than a test using the real thing. This additional layer is also error prone. In my opinion, the method used in the Act section should always be the very method we want to test.

In your original example, you use anonymous variables to make irrelevant parameters more transparent, I think it's the sensible way to go to simplify your tests, like

```<code>fooObject.Foo("", 0, (bar)=>{}, (bar)=>{});
</code>```

Title: UnitTests, will cleaning up your act-statement make your test more or less clear?

Body:
Lets say that we are testing FooClass with the following method:

```<code>    public void Foo(string stringParameter, int intParameter, Action<Bar> successCallback, Action<Exception> errorCallback);
</code>```

If the call to Foo succeeds, the successCallback will be called with the result of Foo in the form of a Bar object. If it fails, the errorCallback will be called with an Exception.

So the tests will look something like this:

```<code>[TestMethod]
public void Foo_UnderGivenConditions_WeExpectAGivenResult()
{
    //Arrange
    var fooObject = CreateFooObjectWithGivenConditions( ... );

    //Act
    fooObject.Foo(String.Empty, 0, (bar) => { ... }, (error) => { ... });

    //Assert
    Assert.AreEqual(..., ...);
}
</code>```

Now, there are a lot of tests on this Foo-method, all of them containing a call to Foo, but not every test will care for all the parameters. Some may provide different string values, but doesn't care about the int param, and some will need to provide an error callback to assert that the right exception is thrown and so on.

Now, since all the parameters are mandatory, we have to pass a string value to the Foo method, even though the value has no meaning for the test. There will be a lot of "I don't care" or "some text". When some one else comes and read the test, they have to consider if the given value actually has a meaning for the test result or not. The same goes for the callbacks. Sometimes we need the callbacks to get to the result value or the exception, but most of the time we do not.

So lets implement an extension method, PerformFoo, that defaults every parameter:

```<code>public static Bar PerformBar(this FooClass fooObject, string stringParameter = "some text", int intParameter = 0, Action<Bar> successCallback = null, Action<Exception> errorCallback = null);
{
   Bar result = null;

   var ourCallback = (bar) =>
      {
          result = bar;
          if (successCallback != null)
              sucessCallback.invoke();
      }

   fooObject.Foo(stringParameter, intParameter, ourCallback, errorCallback);

   return result;
}
</code>```

The extension method will call Foo with default parameters, and even return the result if the successCallback is called. This lets us change the Act part of the test to something like:

```<code>//Act, all we care about is the string parameter:
fooObject.PerformFoo("A string that we care about");

//Act, we need the resulting bar when the int parameter is 10:
var bar = fooObject.PerformFoo(intParameter: 10);

//Act, we still needs to provide a callback to get the exception
fooObject.PerformFoo("SomeInvalidValueCausingAnException", errorCallback: (error) => { exceptionThrown = error; });
</code>```

So the questions would be:

Does this make the tests more readable?

Is it easier to get what the test really tests?

The fact that we call PerformFoo, which doesn't really exist on the class under test make the test less worth as an documentation?

Would dropping the extension method for a regular method taking the fooObject as the first parameter be less of a 'lie'? (e.g. PerformFoo(fooObject, intParameter: 10) )

How far would you go to make your tests clean and clear?

Body:
//Act, we need the resulting bar when the int parameter is 10:
var bar = fooObject.PerformFoo(intParameter: 10);

As a developer coming across this unit test, it'd take me a few seconds to get beyond that "proxy" method and figure out which behavior of the class under test is actually tested, as there is no direct mention of the original method. So I wouldn't say it is more readable than a test using the real thing. This additional layer is also error prone. In my opinion, the method used in the Act section should always be the very method we want to test.

In your original example, you use anonymous variables to make irrelevant parameters more transparent, I think it's the sensible way to go to simplify your tests, like

fooObject.Foo("", 0, (bar)=>{}, (bar)=>{});

ContentLicense: CC BY-SA 4.0


答:
I propose the following implementation in Python:

```<code>class Map(dict): pass
</code>```

It has the following advantages:

Get/Set access via map[(1,2)] can be considered O(1).

The need to explicitly extend the grid vanishes.

There is little space for bugs.

It is easily upgraded to 3D, if ever necessary.

Title: Infinite Bitmap

Body:
I'd like to build a bitmap during runtime. The bitmap should be scalable on all sides and pixel access should be quiet efficient.

Some illustration http://img546.imageshack.us/img546/4995/maptm.jpg

Between and after the commands shown in the picture, Map.setPixel() and Map.getPixel() should set/return data saved in the bitmap.

I don't expect an implementation just a concept how to allocate memory in such a way that the setPixel()/getPixel is as fast as possible.

Body:
I propose the following implementation in Python:

class Map(dict): pass

It has the following advantages:

Get/Set access via map[(1,2)] can be considered O(1).

The need to explicitly extend the grid vanishes.

There is little space for bugs.

It is easily upgraded to 3D, if ever necessary.


问:
What constitutes authorship for software documentation?
In science, intellectual contribution to a project is sufficient for someone to be the author of a document. When writing software documentation, this would imply that almost everyone involved in the software development would be included as co-authors.

Unlike in science, it seems odd to include the names of people who do not actually work on the document. One reason is that documentation is constantly evolving and I am concerned about making sure that co-authors regularly review the current state of the document.

question: When writing documentation, are there guidelines for whom, other than those who directly contribute to the document, should be considered an author?

clarification: I am writing documentation about how to use an open source software and database built by and for scientists. As this project represents most of our the team's cumulative experience with software development, we have no existing policies for authorship of documentation (unlike we do with journal articles).

答:
In my experience, the author or authors are the people who actually contribute core content to the document and produce the work. Other people who might sign-off on the document are listed as "reviewers". Typically, there will be two pieces of information associated with every name - their role in producing the document (as an author/contributor/originator or a reviewer) and their role in the organization (software engineer, project manager, software lead, quality assurance, and so on).

However, this depends on organizational policies. Your team or organization should decide who writes what types of documents, who has to review, how those reviews are documented, and how to capture any kind of required sign-off. This should be captured as part of your configuration management procedures - documents need to be controlled just as much as source code does.


答:
Depending on what sort of documentation it is, NO authors should be named or the company / organization publishing the document is listed as the author.

For example,

Microsoft's code contracts documentation.

Cisco's user guides for their products

Dell's user guides

Lenel's cut sheets

Be warned: all above links are to PDFs, some of which are quite large.

Title: What constitutes authorship for software documentation?

Body:
In science, intellectual contribution to a project is sufficient for someone to be the author of a document. When writing software documentation, this would imply that almost everyone involved in the software development would be included as co-authors.

Unlike in science, it seems odd to include the names of people who do not actually work on the document. One reason is that documentation is constantly evolving and I am concerned about making sure that co-authors regularly review the current state of the document.

question: When writing documentation, are there guidelines for whom, other than those who directly contribute to the document, should be considered an author?

clarification: I am writing documentation about how to use an open source software and database built by and for scientists. As this project represents most of our the team's cumulative experience with software development, we have no existing policies for authorship of documentation (unlike we do with journal articles).


问:
Are compilers used outside of development?
As far as my understanding goes, compilers are meant for developers compiling their code into executable (machine-code) files. Compilers don't extend to a client's machine or end-user system.

Instead, developers just use the compiler to convert their code into machine code, which is then transported to the other machines for use as applications.

Do compilers have a function outside of this process? If so, when are they used?

答: Yes, compilers are mainly used by developers, with a couple of notable exceptions.  End users sometimes use compilers to compile and install the latest open source software, even if they don't make any changes to the code.  Also, some programming languages don't have compilers.  They use interpreters instead that "compile" on the fly.  In that case, end users need to have the interpreter installed on their machines.</p>


答:
That's right -- compilers compile source code into executable form, which is then linked into an executable binary file by a linker. Source code can also be executed directly by an interpreter such as one of the many command-line shells (C-shell, bash, zsh, etc.), awk, sed, and so on.

It can be hard to draw a clear line between "developer" and "end user" unless you limit your discussion to a specific product. Developers are all "end users" of the tools they use, and "end users" may have development tools such as compilers and interpreters installed on their machines.

Title: Are compilers used outside of development?

Body:
As far as my understanding goes, compilers are meant for developers compiling their code into executable (machine-code) files. Compilers don't extend to a client's machine or end-user system.

Instead, developers just use the compiler to convert their code into machine code, which is then transported to the other machines for use as applications.

Do compilers have a function outside of this process? If so, when are they used?


答:
compilers are meant only for developers for compiling their
  programming-language code to executable(machin-code) files

I would say "compilers are meant primary for developers ...". But I have seen examples where programs generate new programming-language code on-the-fly and therefore need a compiler to be installed on the end users machine. That does not mean the end-user has to work with the compiler by itself.

Possible reasons for this program design:

performance: think of a rule-driven application where the rules are stored in some kind of end-user data store and you have some mass-data to be processed by those rules. Instead of interpreting the rules again and again, a program generates the processing code first, compiles it and runs it against the data to be processed

think of a program where the end user can add some kind of math formula and the developer of the program does not want to implement his own parser/interpreter for this. Instead, the program takes this formula, makes some additions to transform it into a valid piece of program code, let the compiler compile it and runs it afterwards.


答: Administrators may also have a need for using programming languages in writing scripts to perform various automated tasks.  For example, having a script that deletes old log files off a server after 90 days to free up some disk space.  The language used to write the script has to be interpreted or compiled so that it can be run on the system.</p>


问:
What are the reasons that make PHP more popular for freelancing world?
In many freelancing websites, you see many job ads for PHP (backed by MySQL). However, job ads for .NET, Java, Ruby, etc. are not that much. What are the reasons which make PHP so popular for freelancing? Is it because of its importance? Or is it because PHP is free?

The reason I'm asking this question is that, I'm an ASP.NET developer and while I see that ASP.NET development productivity is higher (because of fascinating tools it has), it still doesn't attract developers as much as PHP. I want to know if I'm missing something here that I should take into account or no.

答:
IMO the answer is a very low barrier to entry, and very little required to get started, not to mention a plethora of free tools to get up and running quick.  You can set up a PHP development environment relatively quick and for the princely sum of $0.  You can set up a PHP server for $0, and for production hosting it's typically cheap as dirt; a couple of bucks a month.

Compare that to .NET, which requires a few thousand (unless you are part of a program that gives you it for free e.g. BizSpark) dollars for licenses and software, another thousand or so for high-end tools (You can use Express, but compare to PHP where Eclipse/Netbeans/Aptana/etc. are free and fully-featured).  Or compare that to Ruby and Python and their frameworks which require more knowledge and are still relatively unknown in most major areas.


答:
Yes

A compiler is defined as a program that translates code from one language into another (see Wikipedia). The most common use of compilers is to translate the source language into machine code, but this does define the word "compiler".

For example, Python generates byte-code when it imports a module, and thus fits within the definition of a compiler (because it converts from the source language, Python, into the target language, Python byte-code).

Another example is the V8 JavaScript engine. It converts JavaScript into x86 machine code, and thus fits into the definition of a compiler as well. Not only does V8 fit the definition of a compiler, but it is included in Chrome and is very widely used on client machines.


答:
One case would be for an application that dynamically generated code at runtime, and then ran the generated code. This code would need to be compiled at runtime.

Edit: There are other exceptions, but they had already been mentioned in other answers.


问:
Where to look for challenging jobs with a relaxed atmosphere?
I'm a dev at one of the big-name tech companies. I like the job for many reasons:

I do interesting work on a cool product

I solve challenging problems and use a lot of high-level skills (quantitative, creative, writing, presenting)

It pays well

The problem is that I feel I need a more relaxed atmosphere (shorter hours, less performance pressure, and more flexibility), in order to free up time for other pursuits and reduce stress. The ideal would be a job that's around 30-35 hours a week, where there is flexibility to work more or less in a given week. Can anyone suggest where to look for a job like this, where I wouldn't have to sacrifice too much on the above points? (Obviously I would have to sacrifice pay.) My employer does not generally offer part-time employment.

The closest thing I can think of is when I did summer internships at my university's CS department. The work was very intellectually challenging, but if I needed to go home a couple hours early or get flexibility on a due date, nobody batted an eyelash. However, I'd like to find out if there are alternatives to academia since from what I've seen the pay there is a gigantic drop from what I'm currently making.

I've done freelance development before, but I do like that as an employee of a large company I have a lot of things taken care of for me (e.g. benefits and guaranteed stable employment).

答:
I've done that before, in the following situations:

As a contract programmer I've worked several places (often in govt) where reduced hours are the norm. For example, my local municipal govt requires everyone take every second friday off as a budget-cutting measure. The rest of the time it's normal business hours. I've also done several contracts where the hour requirements were very flexible. If your rate is high enough, they expect you to be productive when you're there, but if you've done your work, you don't have to hang around to run up the bill.

I currently work as at a law firm, and the standard hours for the firm is 7hr/day (plus 1 hour for lunch). There's also a lot of flexibility in start/end times, along with flexible vacation days.

Ask in interviews. Ask about flex and vacation days. See if there are opportunities for working from home. Find out if they pay overtime, or if they give time off in lieu. Either policy will encourage less overtime from the top down.


答:
The line manager ... has the Product Backlog in his head and also prioritizes it.

consider printing a large poster of this and placing it on the wall right where your SCRUmanager can clearly see it: Manifesto for Half-Arsed Agile Software Development ...while the items on the left sound nice
in theory, we’re an enterprise company, and there’s no way we’re letting go of the items on the right.

Title: Scrum roles mixed up


答:
Yes and no. Yes, the classical scenario is a developer using a compiler to generate machine code from source code, and the machine code is then distributed to the users.

There are a few exceptions to this though. First, many open source projects are distributed primarily (or even exclusively) in source code form, and expect the end user to install them by typing in a couple of commands like make and then make intall. This will invoke the compiler, linker, etc., to generate the machine code from the source code for that users computer. In these cases, however, the process of building and installing is (at least intended to be) automated to the point that the user rarely needs much knowledge of it beyond the fact that if they've never installed a source code-only package previously, their package manager will typically list some "development" package as a prerequisite for installing the application they really care about (though some still see this as unfriendly to end users).

Another exception (that's been alluded to, but not explained very well in the other answers I've seen) is just-in-time (JIT) compilers. A couple of obvious examples of JIT compilers are the Microsoft Common Language Runtime (CLR) and the Java Virtual Machine (JVM). In these cases, there are normally two entirely separate compilers involved in translating source code into machine code. One is used by the developer. However, rather than generating machine code directly, it generates a machine-independent byte code. The CLR/JVM then includes a second compiler, entirely separate from the first, that converts those byte codes to machine code for the target computer.

I should add that the second compiler isn't strictly necessary. Early versions of the JVM (for one example) just interpreted the byte codes instead of compiling them. This often carries a fairly serious performance penalty though, so most reasonably recent JVMs intended for production use include a JIT compiler.


问:
Is there a name for the not given/null/empty-problem?
I work with code, where data is stored/exchanged in Hashtable/Dictionary/Associative-Array-like structures, like this

```<code>{
   'alpha': None,
   'bravo': '',
   # 'charlie' is not given
}
</code>```

there is not much standartization, which field is 'given', and when given, if it may be given as None/Null/Nil or an empty string. As a result, the code is littered with checks like if hasattr(obj, 'alpha') and default fallbacks.

Is there a name or slang term for this kind of (imho) anti-pattern?

UPDATE:

it seems, currently there is no name, so i'd like to hear suggestions. Currently we have these:

Incorporeal Horde (credits to psr)

答:
In F# this is provided through an Option Type (similarly to earlier languages in the same family).  I have used the same concept in a C# project where I have a rule that I try to never return null from a function, but I return the Option<T> of that type of there's a possibility of a None value.  That way the calling code knows that it has to deal with that possibility in the return value.

I would prefer to have non-nullable reference types, just like we now have nullable value types, but that's another story.


问:
Single Line Statements & Good Practices
I have recently acquired a habit which I know many of you may frown upon, but which, in the end, helps me keeping an eye on global code structure rather than on the structure of a single, (sometimes) repetitive method: grouping a number of statements in a single line, like this:

textBox1.Text = "Something!"; textBox2.Text = "Another thing!"; textBox3.Text = "Yet another thing!";
```

<p>as opposed to</p>

<pre class="lang-cs prettyprint-override"><code>textBox1.Text = "Something!";
textBox2.Text = "Another thing!";
textBox3.Text = "Yet another thing!";
</code>```

I use to do that for repetitive tasks to maintain overall code "beauty" and to help me tracking program structure easily, but I admit it may not be a good practice. I actually use it a lot, so I would like to know what are your thoughts on this. Also, do you think that anyone which would ever have to maintain my code have problems with this approach?

答:
I wouldn't personally use such a style. To summarize

Pros

fewer lines of code to scroll through

can be used to semantically group code to express: "a lot of assignment stuff". BUT you can always refactor such a block into a function if it bothers you too much.

Cons

difficult to read, it's generally easier to read code horizontally (skimming, no eye movement, ...)

diff easily becomes a nightmare, including merging

more difficult to change (copy&paste, commenting out, ...)

debugging can be a problem in many IDEs as they work on lines instead of individual expressions.

Title: Single Line Statements & Good Practices


答:
I don't think there is such a name (I looked, but of course how can you find a lack of a name)?

I suggest the name "Incorporeal Horde", though I would apply it to the full collection of null or degenerate objects - zero size collections, null, undefined, nothing, None, NAN (arguably is a different kind of edge case), DBNull, void, empty string (arguably an empty collection special case), missing dictionary entries, etc.

And I wouldn't call it an anti-pattern, per se, but as an issue in software development, especially in the case where your programming environment requires you to write separate code for many of those cases.

Apologies for a fairly non informative answer, but I think it's the best that can be done.  Plus, if the world adopts a name due to your question it could become a correct answer.

Title: Is there a name for the not given/null/empty-problem?

Body:
I work with code, where data is stored/exchanged in Hashtable/Dictionary/Associative-Array-like structures, like this

```<code>{
   'alpha': None,
   'bravo': '',
   # 'charlie' is not given
}
</code>```

there is not much standartization, which field is 'given', and when given, if it may be given as None/Null/Nil or an empty string. As a result, the code is littered with checks like if hasattr(obj, 'alpha') and default fallbacks.

Is there a name or slang term for this kind of (imho) anti-pattern?

UPDATE:

it seems, currently there is no name, so i'd like to hear suggestions. Currently we have these:

Incorporeal Horde (credits to psr)


问:
How do you decide where functionality should belong in a large-scale project?
In my current development situation, we have a lot of DLLs, executables, and static libraries. How do you decide what should go into a DLL? What should go into an executable? Why have separate functionality in different executable files? I'm hoping the answer will be concise, but this is a largely opinionated topic it would seem.

How do you decide where functionality resides in a large-scale project (more than one executable file)? I'm expecting answers to range from, "Good Design" to "Modularity" to "Whatever management puts in a requirements doc".

答:
A simple way to approach an answer is to recognize that "DLL" stands for "dynamic-link library," and the key term is "library."

What do you want in a normal library?  Good books that will be shared by many readers (users); useful items that gather dust until referenced by a reader (user) to answer a critical question at a perhaps desperate moment; and resources that link readers (users) to other resources.  Code libraries are similar.  We keep such things as frequently shared code, specialized or high-value reference modules, and architectural framework resources in them.  Software libraries can be represented in several kinds of code artifacts, such as scripts, static libraries, dynamic libraries, components, and resource files.

Generally, I recommend making your executable modules act somewhat like scripts.  They clearly outline and manage the main structure and flow of your system but call upon resources from your libraries to handle the nitty-gritty details.  I find this approach better than muddying up high-level logic with confusing and overly specialized and technical low-level implementation concerns.

When considering how to allocate your code between executables and libraries, you need to consider both logical design and physical design.

In object-oriented systems, for example, it is important to logically organize your code to correctly assign responsibilities to the right methods in the right classes.  This is part of logical solution design.  Your logical design should be clear, clean, and lean and should be expressed in terminology that relates well to your users' domain.

When you plan to actually install your system on a user's site, you may be concerned to create a physical design that specifies how you will bundle your code into a set of easily deployable software resource objects (usually files) that can be readily mixed and matched to the needs of a particular target system.  Determining which resources belong in which deployment package may generally involves some specific physical design considerations that have nothing directly to do with logical design.  For example, you may want to swap out certain image file processing libraries depending on which customer will receive a given set of deployment objects.

In practice, you will find that good logical design usually leads to good physical design.

To summarize, the most important principle is intelligent packaging.  By organizing your code materials into strongly related libraries, you end up with useful deployable code artifacts that you can easily re-use, move around, or give away.


答:
You can play the "How long would it take you to write this?" game.  Similar to a group of people bragging about how they can drive to Las Vegas in X hours (where the number X usually decreases with each braggart until someone claims they can do it in under an hour).  So for coders: Throw out a simple goal and see what each individual says and if there is a consensus by the group or standout opinions.  How long would it take you to write hello world?  What does "write" mean, does that mean "run" and "test" too?  Does it require a simulation environment first?  On which platform and which cross-compiler and are the tools already installed and ready?   etc etc..   "Hello world" might take 4 days to "write" on an embedded platform (install tools, get platform ready, re-install tools because it went wrong, fix the JTAG problem, troubleshoot the serial port problem, work around the limitations in the IDE to make a compilable project, finally take 5 minutes to write the code, compile it, fix the link errors and the memory map, re-write the code to use the correct bootstrap, re-compile it, get the final link, then download it, fix the JTAG problem again, finally run it to get output).

After the team finishes deciding how long the goal might take, then measure how long it actually takes (perhaps not for the suggested goal but for a real-world similar one) or recall a previous project with very similar goal.  Compare estimate to actual.  Wildly exaggerate the error between the estimate and actual and publish a conclusion for all.


答:
You can do it at your current job (35 hours a week means only subtracting 1 hour for every work day, or taking a 2 hour lunch break instead of 1).  Just leave early.  Your manager won't call you a slacker until at least your next performance review which could be in 1 year.  It helps if you hang out with marketing or app engineers or other employees with travel schedules (so work hours are incredibly flexible) so that your absence can be ascribed to "flex time" rather than complete slack-off.  If your manager is "busy" (either overseeing too many underlings or just not paying attention) then it may never be noticed that you are slacking.  In fact you may get a promotion!  It seems plenty of managers behave by these rules already..  Exaggerating this a bit, you may be able to get down to about 30 hours per week.. without change in pay.. there's examples at every company of employees slacking like this.   (As the saying goes:  start smoking, you get more work breaks!)

As to the eventual down voters who don't "like" the above approach: Hey, the asker asked!

Title: Where to look for challenging jobs with a relaxed atmosphere?

Body:
I'm a dev at one of the big-name tech companies. I like the job for many reasons:

I do interesting work on a cool product

I solve challenging problems and use a lot of high-level skills (quantitative, creative, writing, presenting)

It pays well

The problem is that I feel I need a more relaxed atmosphere (shorter hours, less performance pressure, and more flexibility), in order to free up time for other pursuits and reduce stress. The ideal would be a job that's around 30-35 hours a week, where there is flexibility to work more or less in a given week. Can anyone suggest where to look for a job like this, where I wouldn't have to sacrifice too much on the above points? (Obviously I would have to sacrifice pay.) My employer does not generally offer part-time employment.

The closest thing I can think of is when I did summer internships at my university's CS department. The work was very intellectually challenging, but if I needed to go home a couple hours early or get flexibility on a due date, nobody batted an eyelash. However, I'd like to find out if there are alternatives to academia since from what I've seen the pay there is a gigantic drop from what I'm currently making.

I've done freelance development before, but I do like that as an employee of a large company I have a lot of things taken care of for me (e.g. benefits and guaranteed stable employment).


问:
Remake old web forms application in asp.net mvc
I've inherited the code maintenance of a complex web site for a customer that continuously requests enhancements for it. This application took years to develop and I'm facing increased difficulties to enhance it. It's organized but at the same time the .net code is mixed with ajax, javascripts and old school html that it takes me days to figure out how some pages work.

First off, I not new to asp.net but I'm not familiar with the new MVC stuff but from what I've read it seems to be a step in a better direction.

The current code is all in one big dll. The application code is divided into multiple folders representing the different departments and each department has it's own pages for handling general stuff like employee management, reports, budget and also their own information.

For example, even though each department uses a different webpage for employee information handling, they want different fields and so it was simpler to create different pages than to use a single page that adapts to each department.

But it is really a nightmare to maintain right now and I would like to create a parallel project where I could start a fresh project, create a better structure and from there start migrating the old code to this new environment and refactor it as I go.

The idea is to migrate the old application to a new web site that has a similar look while maintaining both operating until everything is running in the new site.

It may sound insane but it really is used extensively for hundreds of people everyday and it bugs me that I have to modify crappy code to make it work.

How would you go about this issue?

[edit]
If found this link Things You Should Never Do on another post, very much to the point of my question.

答:
Don't be so hasty

I know dealing with other people's code really sucks, but you have to take into consideration that 1- you don't know the new MVC platform, and 2- down the road you will be wanting to remake it again. Consider that rebuilding the project also takes time away that you could use upgrading it.

No Surprises

People don't like surprises in the software realm. I can tell you plenty of horror stories of software that was remade without the client's knowing and upon the surprise revealing, an instant, terrible rejection.

The best solution is to talk to your boss and discuss options. They may even want to integrate more features or go in a different direction. After all, your time is their money.

One More Option

It might be better to spend more time learning it and to slowly build up components that are causing trouble. I sense that you are having some trouble understanding all of the software's functions and going into a remake with those same confusions will only drag those misunderstandings into the new project.

Related SO Questions

Refactor or Rewrite?

Refactor/rewrite code or continue?

OwnerDisplayName: Hfux


答:
In my opinion, converting an application that took years to develop to MVC is probably not realistic. It would probably take you just as long to convert it to MVC, becasue the implementation would be totally different, and you would have to find other ways to implement the existing features. I doubt that this client who regularly asks for enhancements would be willing to wait for a couple of years while you're trying to convert it to MVC. From a business perspective, that's just not practical. You would be changing it for you, so it's easier for you to work with, which is not a business incentive for them.

If there is a particular aspect of the system that makes it difficult for you to build enhancements, focus on improving that aspect of the system. Resign yourself to the fact that it's a web forms application, and find ways to make it easier for you to work with. Developers tend to think about what they would like, and how they like to work, but you have to think about the client and how your preferences will impact their business and their bottom line.

My advice is to work within the current design to make certain parts of it easier to work with.

Title: Remake old web forms application in asp.net mvc

Body:
I've inherited the code maintenance of a complex web site for a customer that continuously requests enhancements for it. This application took years to develop and I'm facing increased difficulties to enhance it. It's organized but at the same time the .net code is mixed with ajax, javascripts and old school html that it takes me days to figure out how some pages work.

First off, I not new to asp.net but I'm not familiar with the new MVC stuff but from what I've read it seems to be a step in a better direction.

The current code is all in one big dll. The application code is divided into multiple folders representing the different departments and each department has it's own pages for handling general stuff like employee management, reports, budget and also their own information.

For example, even though each department uses a different webpage for employee information handling, they want different fields and so it was simpler to create different pages than to use a single page that adapts to each department.

But it is really a nightmare to maintain right now and I would like to create a parallel project where I could start a fresh project, create a better structure and from there start migrating the old code to this new environment and refactor it as I go.

The idea is to migrate the old application to a new web site that has a similar look while maintaining both operating until everything is running in the new site.

It may sound insane but it really is used extensively for hundreds of people everyday and it bugs me that I have to modify crappy code to make it work.

How would you go about this issue?

[edit]
If found this link Things You Should Never Do on another post, very much to the point of my question.

OwnerDisplayName: James Johnson


答:
I agree with everything @rlb.usa says.  Another risk you have is that you'll never finish migrating the code if you take it one step at a time based on enhancement/change requests.

That may leave you with a bigger maintenance headache than you have now as there will be even less consistency in the architecture.  And, it will surely create more confusion for the next developer that comes along.

OwnerDisplayName: JasonS


答:
If you actually need a bitmap of any arbitrary size - and I mean anything from 1x1 to 1000000x1000000 amd up, and need it expandable on demand... one possible way is to use a database.  It may seem counter intuitive at first, but what you really have is a storage problem.  A database will let you access individual pixels and store essentually any amount of data.  I dont necessarily mean an SQL db, btw.

Will it be fast enough for your purposes?  That I cant answer, as there's no context here regarding what you are doing with this bitmap.  But if this is for screen display, consider that you'd generally only need to pull back the additional scan rows to display as the screen scrolls, not all the data.

That being said, I cant help but wonder if you're going about something wrong.  Should you perhaps instead by using vector based graphic and tracking individual entieties in memory, and then rendering a bitmap only as big as needed for the screen?

Title: Infinite Bitmap


答:
Unless you have the time and resources to dedicate to rewriting the application ASP.NET MVC and rewriting it properly, don't do it.  You'll be in for a world of hurt.  I know from experience how terrible poorly-written WebForms apps can be, but it's a Herculean effort to rewrite it to MVC even with the benefits you'd gain.

Would you be better off doing heavy refactoring/rewriting of specific components to make them more abstract and modular, and using MVP or similar pattern to get some of the benefits of MVC without a wholesale move to that platform?  That could be a better option.  Obviously for any new development that just has to interact with, not be part of, the legacy app should be written in MVC, but heavy refactoring, introducing MVP and proper SoC principles, and slowly rewriting the messiest parts of the code to be written correct will go a lot longer than just scrapping the WebForms behemoth.


问:
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!

答:
A computer lets you make more
  mistakes faster than any invention in
  human history—with the possible
  exceptions of handguns and tequila.

    — Mitch Ratcliffe

LastEditorDisplayName: Roger Pate


问:
What does the term day-one-bug mean?
I came across this term recently in a mail chain. Google tells me there is a term zero-day bug and that Microsoft and Adobe are the frontrunners :)

Is there such a term as day one bug? What might that mean?

答:
A day-one bug is a defect that is not a regression. The defect was there from day one when the feature was implemented. It is used to argue that a defect is low priority, because it has been shipped in previous releases without many complaints from customers.

Citations:

Neohapsis > Archives > Compaq Product Updates> 2001-q4

date - Nov 2001 or earlier

This day-one bug was dormant until the latest release of PATHWORKS. With an older version of PATHWORKS,         conditions were such that the routine was never entered simultaneously. However, the new release has a different set of calls into PWIP and the bug is now exposed...

Cross-Platform Release Notes for Cisco IOS Release 12.2SR: Caveats for 12.2(33)SRB...

date - May 2008?

CSCsl27236... is a day one bug that just surfaced. The customer found this under heavy stress conditions...

[security-dev 01487]:  OCSP Issues in JDK6 - OpenJDK mail archive

date - Jan 2010

Changeset: 95e9083cf4a7... Summary: This day one bug is caused by missing memory barriers in various Parker::park() paths that can result in lost wakeups and hangs...

Title: What does the term day-one-bug mean?


问:
Is an assocative array ordered?
An associative array has many common similar names, hash, keymap, map, table, index.

It's a map of keys and values but I cannot find a reputable definition of the phrase which tells me whether a map has to have order to be an associative array.

What is a reputable definition of the term "Associative array"?

Is an associative array ordereded?

Personally I've always believed they have to be ordered because in JavaScript we claim Objects are not associative arrays because Objects are un-ordered maps of keys and values. However I may have been quoting that without a reference or a source.

答:
The definition from wikipedia seems correct and general enough:

collection of unique keys and a collection of values, where each key is associated with one value (or set of values)

Not a word about order. That should be perfectly fine, as there are many good ways to implement data structures that are perfect associative arrays, only without the "ordered" requirement (if it was there). I've never heard someone claim a "tree map" (as some APIs call it because it internally uses a balanced binary tree) or hashtable isn't an associative array because it's ordered or not. Plus, most code doesn't care if the keys are ordered.

Personally I've always believed they have to be ordered because in JavaScript we claim Objects are not associative arrays because Objects are un-ordered maps of keys and values.

That logic ("AA must be ordered because Objects are not AA because Objects are not ordered") seems a bit circular. Who's we and why are you claiming this? Javascript objects are clearly hash tables, and hash tables are clearly associative arrays by the above and pretty much all other definitions. They're not ordered, yes, but that doesn't change the fact that they are collections mapping strings to objects.

And even if you managed to find a reputable source defining associative arrays to be ordered, there's plenty of people and text out there that doesn't go on that assumption. To be safe, you should explicitly add the "ordered" requirement when it matters and omit it whenever it doesn't matter (which is surprisingly often).

Title: Is an assocative array ordered?


问:
Developing an internet-enabled application as a Kiosk on Windows 7
I am finalizing development of a desktop Java application that communicates with an outside web server, and now I need to start seriously considering deployment.

This application will run on a large touchscreen all-in-one workstation running Windows 7.

It will be located in a public-area and thus must be LOCKED-DOWN Hanibal Lecter style.  Early in the project nobody really concerned themselves with this fact just assuming that we can buy some magical software for Windows 7 that will automatically take care of all this, however I am finding now that this looks to be a LOT more complicated than my manager ever thought.

I need to:
 - Lock down the standard hot-keys (ALT+TAB, ALT+CTRL+DEL, etc...)

Prevent the user from opening ANY programs other than the kiosk application and its spawned executables

Prevent the user from closing the application

Start the kiosk application on startup (this can be done without kiosk software)

Auto-login to Windows on reboot (Windows Updates, power failure, bratty kid pressing the power button, etc...)

Administrator passcode escape sequence for routine maintenance by desktop support professionals.

To my dismay I am having a really hard time finding software that contains the whole package and am finding numerous swaths of competing information on the best way to do this.  I am not necessarily looking for free or open source software and am willing to pay for software that can help me achieve this.

Have any of you ever wrote kiosk software before and if so what approaches have you taken to do this?

答:
Unfortunately, I cannot answer your question on its entirety, but you should be able to use a program like AutoHotKey to "hijack" certain key combinations and change the behavior to simply do nothing.

The AutoHotKey script can be placed in the Startup folder to ensure they're always in effect.


问:
How large non-OO code bases are managed?
I always see abstraction is a very useful feature the OO provides for managing the code-base. But how are large non-OO code bases are managed? Or do those just become a "Big Ball of Mud" eventually?

Update:

It seemed everyone is thinking 'abstraction' is just modularization or data-hiding. But IMHO, it also means the use of 'Abstract Classes' or 'Interfaces' which is a must for dependency-injection and thus testing. How non-OO code bases manage this? And also, other than abstraction, the encapsulation also helps a lot to manage large code bases as it define and restrict the relation between data and functions.

With C, it is very much possible to write pseudo-OO code. I don't know much about other non-OO languages. So, is it THE way to manage large C code bases?

答: The biggest technical challenge is the namespace problem.  Partial linking can be used to work around this.  The better approach is to design using coding standards.  Otherwise all the symbols become a mess.</p>


问:
Can one truly develop a programming style?
I started teaching myself programming half a year ago, and I've noticed I keep using a few basic techniques over and over again, is this the onset of a style or just ignorance of variation?</p>

答:
It's a little of both. For example, some people swear by:

```<code>if () {
    // do something
}
</code>```

whereas others only use:

```<code>if ()
{
    // do something
}
</code>```

That's programming style. For a rookie coder, however, ignorance of variation is certainly a factor. You emulate the style you see, and you probably won't change it around unless you see another structure that you like.

Body:
It's a little of both. For example, some people swear by:

if () {
    // do something
}

whereas others only use:

if ()
{
    // do something
}

That's programming style. For a rookie coder, however, ignorance of variation is certainly a factor. You emulate the style you see, and you probably won't change it around unless you see another structure that you like.


答: Half a year is not a very long time.  My advice would be to keep reading books on programming and software development. No matter what language you are using or what kind of programs you are writing, by reading books you are going to find out just how much you do not yet know. Oh, and you will also find out whether the techniques you are using are the onset of style or beginner's mistakes.</p>

Title: Can one truly develop a programming style?

Body: I started teaching myself programming half a year ago, and I've noticed I keep using a few basic techniques over and over again, is this the onset of a style or just ignorance of variation?</p>


问:
Infinite Bitmap
I'd like to build a bitmap during runtime. The bitmap should be scalable on all sides and pixel access should be quiet efficient.

Some illustration http://img546.imageshack.us/img546/4995/maptm.jpg

Between and after the commands shown in the picture, Map.setPixel() and Map.getPixel() should set/return data saved in the bitmap.

I don't expect an implementation just a concept how to allocate memory in such a way that the setPixel()/getPixel is as fast as possible.

答:
Constant size tiling (say, 256x256, but with infinite number of tiles)

Provide a bitmap wrapper that allows negative pixel coordinates (to give the impression that an image can be expanded in all four directions without having to recompute/synchronize references to existing coordinate values)

The actual bitmap class (working beneath the wrapper), however, should only support absolute (non-negative) coordinates.

Under the wrapper, provide tile-level (block-level) access using memory-mapped I/O

In addition to Map.setPixel() and Map.getPixel() which modifies single pixel at a time, also provide methods which copies and modifies one rectangle of pixels at a time. This will allow the caller to choose the more efficient form of access depending on information available to the caller.

Commercial libraries also provide methods to update: one row of pixels, one column of pixels, scatter/gather updates, and arithmetic/logic blitter operations in one step (to minimize data copying).

(Let's not upvote the hilarious answers ...)

Title: Infinite Bitmap


答: I've spent most of my career working at big name tech companies, and they've all offered most of the conditions you're looking for (save for working hours, the lowest of which has been 37.5/week). Maybe you're just in the wrong big name tech company...?


答:
There's next to no point in rewriting from webforms to mvc. Almost no code will survive the transition, and as you don't know MVC, the outcome won't be great.

The application code is divided into multiple folders representing the
  different departments and each department has it's own pages for
  handling general stuff like employee management, reports, budget and
  also their own information. For example, even though each department
  uses a different webpage for employee information handling, they want
  different fields and so it was simpler to create different pages than
  to use a single page that adapts to each department.

This will be your saving grace -- I've seen this kind of application. Since each piece of the application is basically separate, you have an option to do piecemeal migration to a more sensible system.

Carve out a location in the URL space of the server where this runs that you can place new code. Rewrite screens one at a time, and test the new code to make sure that it works the way you want. Then change the links and redirects in the old application to point to the new screens, and have navigation in the new screens that link back to still active screens in the old application. Basically, you will have two applications sharing a UI. then chip away at the old application screen by screen as you can and write new code in the new application.

You may have to come up with some way to transfer information between the two applications. You can set the application key in your web.config to the same value to allow single sign-on between the two sides. Try to avoid sharing session state if at all possible (you just get a mess if you do.) Delete old screens as they become obsolete. If there are sensible business layer classes or DAL classes, pull them out into a shared library; otherwise, don't bother.


答:
I think that looking at things purely in terms of working hours is a mistake.

The real difference between 30-40 hours a week is not that significant especially if you have a long commute and are not talking about working 4 days instead of 5. My experience is that unless you work less days, it doesn't really matter all that much. Once you go over 45-50 hours, every hour starts mattering.

Different workplaces have different approaches to time. Some have longer hours where the actual time is more relaxed, and others have shorter hours but somebody constantly makes sure you are typing at your desk and not veering anywhere.

Time is also about perception - 8 hours of something you enjoy can be shorter than 5 hours of something you absolutely hate.

It's legitimate (and important) to ask about flex time when you are negotiating an offer, and also ask your future TL about the actual working hours. I have interviewed in places where the hours were simply too long for me to maintain work-life-balance with a family and they openly admitted it. Others are quite family friendly.


答:
Yes, it means that you believe that the code you wrote needs nothing more. When you're going to develop something more complicated, you automatically search after better methods to solve your problem.

Also:

After a while you are going to be tired of writing the same over and over again and you are going to search new methods to do the same faster. When I started scripting in PHP I made everything myself. After a couple of years I was so tired of it that I searched for a solution. This is were frameworks came in.

After using my first framework I had the feeling I could speed up even more, and start searching again and found even a more complicated framework that does even more then the first one.

Moral of my story:

Now after all these years my style improved just by exploring new things and read a lot of books and tutorials and so I developed my "own" style. But this style is continuous changing, this keeps programming a challenge too.

PS: I set my brackets on a newline I think it's cleaner! :)


答:
It depends. Have you tried different styles? Have you ever pondered about the advantages and disadvantages of these habits of yours? Have you read some articles about the techniques and styles you use (there should be quite a lot of them) for inspiration about those advantages and disadvantages?

Habits are only good or bad if you've given the habits actual thought, instead of just copying them from others and assuming they're good. Be critical and think things through, but don't be /too/ critical either and doubt yourself all the time.