答:
You arrive home one day and you pay check does not...

You want to  take leave, but the team is too busy and has been for a year...

Your wife or child is sick and needs you to cut back to 20 hours a week

for 6 months.

The finance department has called for a budget cut and someone has to go.

The coffee machine broke and no-one can fix it.

Your team is so good there are no defects to fix and no features to add, you have run out of work - what to do now.

The customer won't pay for work done

The customer wants more work done than you can achieve and is prepared to pay for
it.

I don't see anything in this list that has not happened to me in my career. I don't see anything in this list that needs highly technical skills resolve. I see lots of stuff in this list that needs specific skills that, frankly, most developers do not have, and good managers do, no matter what they have managed in the past.

Stop bagging managers - recognize you have a set of skills and they have a different set. All of these skills are needed in any organization. You will do their job just as well as they will do yours. It is rare to have someone good at both jobs, it is rarer to have someone good at both that can do both simultaneously.  What happens without a manger is things slowly erode into a state of disfunction. If you are lucky, its recognized early enough, a manager is hired, and all of a sudden problems disappear as if by magic, and you are left to get on with the job you are paid for rather than playing silly office politics (speaking from experience here).


问:
What is a good algorithm to distribute items with specific requirements?
I have to programmatically distribute a set of items to some entities, but there are rules both on the items and on the entities like so:

```<code>Item one: 100 units, only entities from Foo
Item two: 200 units, no restrictions
Item three: 100 units, only entities that have Bar

Entity one: Only items that have Baz
Entity one hundred: No items that have Fubar
</code>```

I only need to be pointed in the right direction, I'll research and learn the suggested methods.

答:
The most straightforward way is something like this:

```<code>for item in items
    for entity in entities
        if entity.allows(item) and item.allows(entity)
           entity.associate(item)
           break
</code>```

If you have millions of items and entities, and strict performance requirements, then you'd have to get into creating indices for each of the criteria, like a list of all Foo entities, etc.  That's going to add a lot of complexity though, so I wouldn't do it unless absolutely necessary.

ContentLicense: CC BY-SA 3.0

Body:
The most straightforward way is something like this:

for item in items
    for entity in entities
        if entity.allows(item) and item.allows(entity)
           entity.associate(item)
           break

If you have millions of items and entities, and strict performance requirements, then you'd have to get into creating indices for each of the criteria, like a list of all Foo entities, etc.  That's going to add a lot of complexity though, so I wouldn't do it unless absolutely necessary.


问:
Case insensitive keywords in a language
We're trying to write a custom scripting language. There has been a suggestion to make the language forgiving by providing case insensitive keywords.

I personally do not like the idea, but there are few people in my team leaning towards it, saying it will make the end user happy! Examples of languages like FORTRAN, BASIC, SQL are given saying that these are case insensitive.

Is this a good idea?

答:
Programming languages should be case insensitive.

The main reason so many languages these days are case sensitive is simply cargo-cult language design: "C did it that way, and C's incredibly popular, so it must be right."  And as in so many other things, C got this one demonstrably wrong.

This is actually part of the driving philosophy behind C and UNIX: If you have a choice between a bad solution that's easy to implement and a good solution that's harder to implement, choose the bad solution and push the burden of working around your mess off onto the user.  This may sound like snark, but it's absolutely true. It's known as the "worse is better principle," and it's been directly responsible for billions of dollars worth of damage over the last few decades due C and C++ making it far too easy to write glitchy and insecure software.

Making a language case insensitive is definitely easier; you don't need the lexer, parser and symbol tables to have to do the extra work of making sure everything matches in a case insensitive fashion.  But it's also a bad idea, for two reasons:

First, especially if you're building a scripting language, a simple typo where you call something "myObject" in one place and "MyObject" in another, where you obviously are referring to the same object but just got a bit inconsistent with the capitalization, doesn't turn into a runtime error.  (This is infamous as a major pain-point in scripting languages that get this wrong, such as Python.)

Second, not having case sensitivity means that case sensitivity can't be abused to have the same word refer to two different things in the same scope just by changing the capitalization.  If you've ever had to work with Windows code in a C environment, and run into ugly declarations like HWND hwnd;, you'll know exactly what I'm talking about.  People who write like that oughtta be taken out and shot, and making the language case insensitive prevents case sensitivity abuse from making its way into your code.

So make the extra effort to get it right.  The resulting code will be cleaner, easier to read, less buggy, and make your users more productive, and isn't that the ultimate goal of any programming language?

Title: Case insensitive keywords in a language


问:
Floating point undesirable in highly critical code?
Question 11 in the Software Quality section of "IEEE Computer Society Real-World Software Engineering Problems", Naveda, Seidman, lists fp computation as undesirable because "the accuracy of the computations cannot be guaranteed".

This is in the context of computing acceleration for an emergency braking system for a high speed train. This thinking seems to be invoking possible errors in small differences between measurements of a moving object but small differences at slow speeds aren't a problem (or shouldn't be), small differences between two measurements at high speed are irrelevant - can there be a problem with small roundoff errors during deceleration for an emergency braking system? This problem has been observed with airplane braking systems resulting in hydroplaning but could this actually happen in the context of a high speed train?  The concern about fp errors seems to not be well-founded in this context. Any insight? The fp is used for acceleration so perhaps the concern is inching over a speed limit? But fp should be just fine if they use a double in whatever implementation language.

The actual problem in the text states: During the inspection of the code for the emergency braking system of a new high speed train (a highly critical, real-time application), the review team identifies several characteristics of the code. Which of these characteristics are generally viewed as undesirable?

The code contains three recursive functions (well that one is obvious).

The computation of acceleration uses floating point arithmetic.

All other computations use integer arithmetic.

The code contains one linked list that uses dynamic memory allocation (second obvious problem).

All inputs are checked to determine that they are within expected bounds before they are used.

答:
Floating point is only undesirable if you use the wrong method for comparing two values (an equals sign instead of a delta, or extreme ranges where the relative error (ulps) is too great).  FP numbers are not bad for realtime systems per-se.

However, recursive functions and dynamic memory allocation are, for obvious reasons; the real-time performance of these can be difficult to predict.


问:
Does a mature agile team requires any management?
After a recent heated debate over Scrum, I realized my problem is that I think of management as a quite unnecessary and redundant activity in a fully agile team. I believe a mature Agile team does not require management or any non-technical decision making process whatsoever. To my (apparently erring) eyes it is more than obvious that the only one suitable and capable of managing a mature development team is their coach (who is the most technically competent colleague with proper communication skills). I can't imagine how a Scrum master can contribute to such a team.

I am having great difficulty realizing and understanding the value of such things in Scrum and the manager as someone who is not a veteran developer but is well skilled in planning the production cycles when a coach exists in the team. What does that even mean? How on earth can someone with no edge-skills of development manage a highly technical team? Perhaps management here means something else?

I see management as a total waste of time and a by-product of immaturity. In my understanding a mature team is fully self-managing. Apparently I'm mistaken since many great people say the contrary but I can't convince myself.

答:
I'm on a small team with no manager and it works.  Why?  I honestly don't know.

My best guess is it comes down to the type of person you are. Some people "are" computers, so they need to be fed a process. Other people are "programmers" and have the ability to create their own world and structure from nothing.

I must create a system or be enslaved by another mans; I will not reason and compare: my business is to create. --William Blake

EDIT in response to glenatron's comment:

It's more than just a dev team. We have a CEO, a receptionist who answers the phone, and an IT guy. We communicate with clients directly by email, phone, or meetings. Our main business is creating our own product and selling it, rather than hunting down contracts. But there are contracts too.

I've thought about it more and these are the reasons I think it works:

1. We primarily create our own product rather than creating someone else's.

2. We have a consistent work ethic independently without oversight.

3. We have domain knowledge.

4. Luck. A handful of people who get along and work well together.

Someone mentioned the company Valve has no management either. Valve creates their own product rather than creating someone else's. I think a product company lends itself better to self-management. There's no risk of going down a different path than the client expects because you are the client. In a game company this is especially true. Make your game fun.

You can't manage your way to fun. You can't manage your way to the original creation of art.


问:
When do you change your major/minor/patch version number?

Possible Duplicate:

  What “version naming convention” do you use?

Do you change your major/minor/patch version numbers right before you release or right after?

Example: You just released 1.0.0 to the world (huzzah!). But wait, don't celebrate too much. 1.1.0 is coming out in six weeks! So you fix a bug and do a new build. What's that build called? 1.1.0.0 or 1.0.0.xxxy (where xxxy is the build number of 1.0.0 incremented)?

Keep in mind you may have 100 features and bugs to go into 1.1.0. So it might be good to call it 1.0.0.xxxy, because you're nowhere close to 1.1.0. But on the other hand, another dev may be working on 2.0.0, in which case your build might be better named 1.1.0.0 and his 2.0.0.0 instead of 1.0.0.xxxy and 1.0.0.xxxz, respectively.

答:
We try and follow the Eclipse example.  It does a better job of explaining than I can, but effectively for us it works like this:

When you release 1.0.0.0 the version number you change to is dependent on the type of change that you are making.

A release that does not effect the API, consider a behind the scenes bug fix that makes the current API work in the expected way, is released at 1.0.1

A release that adds to the API but does not change the existing API, you may have added a new feature that does not make current clients incomparable with the new version.  This can include any number of the above fixes as well.

A release breaks the current API, removing something, changing something in the way that breaks the comparability with current clients.  This can have any umber of the above fixes as well.

As for how to use the 4th section in the version number we use this to differentiate different builds in Nuget (the package managment solution we use for .net).  This allows us to avoid having to clear the caches each time we need to update our unreleased software.


答:
In larger projects/organizations, the major and minor version numbers are controlled by marketing departments and are usually incremented for marketing reasons. At my organization, groups aim to release one major and one minor release each year. The expectation is that major releases contain significant new functionality and there is binary compatibility between APIs for all releases with the same major version number. However, marketing may choose to downgrade a major version change to minor because promised features are not delivered or vice versa to been seen to leap frog competition, for example.

The major and minor build numbers (c and d in a.b.c.d) are usually controlled by development. c is the build number and d is used for patches on a particular release or version of c.

In your case, when you change the major and minor version numbers is less relevant than ensuring the major and minor build numbers are accurate. At my organization, we change the major and minor build numbers as part of the branching process in source control. The main branch usually contains the latest version but marketing may not have decided what version number the release will have yet.

Title: When do you change your major/minor/patch version number?

Body:
Possible Duplicate:

  What “version naming convention” do you use?

Do you change your major/minor/patch version numbers right before you release or right after?

Example: You just released 1.0.0 to the world (huzzah!). But wait, don't celebrate too much. 1.1.0 is coming out in six weeks! So you fix a bug and do a new build. What's that build called? 1.1.0.0 or 1.0.0.xxxy (where xxxy is the build number of 1.0.0 incremented)?

Keep in mind you may have 100 features and bugs to go into 1.1.0. So it might be good to call it 1.0.0.xxxy, because you're nowhere close to 1.1.0. But on the other hand, another dev may be working on 2.0.0, in which case your build might be better named 1.1.0.0 and his 2.0.0.0 instead of 1.0.0.xxxy and 1.0.0.xxxz, respectively.


答:
I generally try to use SemVer for internal version numbers. It's nice to be able to know something about a release based on the semantics of its version number.

During development, I try to change version numbers straight away (if possible). Sometimes it is hard to know whether the change will be a breaking change or not (which will influence my version number), so nothing is "set in stone".

To address your specific example:

During development, pre-release versions would be 1.0.1-alpha.1, 1.0.1-alpha.2, etc.

The final release of the bug-fix would be version 1.0.1.

Having said that, the 'public-facing' product version numbers are often set by marketing, and are completely different. This is out of my control, so no point worrying about it.


问:
Where is the application of Calculus (of continuous quantities) in Computer Science or programming
I am a Software Engineer professional. I have studied calculus as a core course in my graduation studies. I want to ask question, that what/where is the implementation of calculus in computer science?</p>

答: For this topic, I highly recommend the following book: Concrete Mathematics by Ronald L. Graham, Donald E. Knuth, and Oren Patashnik.    It is about CONtinuous and disCRETE mathematics, and how they are applied in computer science.  Topics include stuff like sums, recurrences, binomial coefficients, number theory, discrete probability, among others.  I reference my copy all the time.


问:
How do you write a linearithmic algorithmn?

Write psuedocode to determine the number of pairs of values in an
  input file that are equal. If your first try is quadratic, think again
  and develop a linearithmic solution.

I found this question in a textbook and I'm not sure how to write this algorithm. My guess at first was to write it along the formula nC2 = (n(n+1))/2. Any help is appreciated.

答:
I don't want to give you the code but some hints. The first thing to pay attention is that the exercise is asking for a linearithmic solutions. This means that you algorithm may consume N log (N) time to execute where N is the number of entries (values in the file in your case).

So the basic structure of the algorithm needed seems to be one loop through all the entries and one binary search inside the loop. To do a binary search you need an ordered entry, so order it. At the end you algorithm may look something like:

Order the file

Loop through the file

Binary read the file during the loop

Check the current value in the loop and the result of the binary search


问:
What happens to programmers most oftenly while reading the code of others?
When reading others code do you usually have any troubles understanding it,
 Or its more usually that you question the others code about it being wrong/non-efficient/bad-formatted(etc)?

Someone reading what you coded on your first job

答:
Short Answer: Mostly we don't like it or get very critical on why coding is done this way, and not the other way around. However, more you read other's bad code, faster you appreciate well written code :)

Although it may sound obvious but the best way to get better at reading people's code is: by reading people's code. The problem is that when people typically read other people's code  they don't try to  "grok" it, i.e. become intimately familiar with it; they do the equivalent of speed-reading poetry.

To grok someone else's code you may try the following:

Refactoring the code.

Choosing a feature to add that requires going into the depths of the code.

Writing comprehensive unit tests for the code.

All of these steps will force you to read the code in greater depth.

There are also some tips how to maximize the understanding of a code-base, that you have been introduce for maintenance and support:

Once you have a basic idea of what's going on, you may want to take a good look at the data storage (the persistence layer). That's another great way to get an understanding of what's happening, but make sure the things you are studying are actually in use. I can remember a few times really getting to the bottom of some classes with this approach, thinking I've understood the system - and then realizing later the classes weren't used at all.

It may seem like a daunting task - it does take time and no fancy tools can remove the need for intelligence - but it can also be very rewarding. As you go, you will probably find a lot of bugs in corner/edge cases, and see ways to improve the code. One piece of advice - don't go too heavy on refactoring / changing until you have a good understanding of the code. Often what looks like a mistake or just plain bad code when you first see it, turns out to be subtle genius at work upon later, enlightened investigation. Also, removing unused code is so satisfying, and great for any future maintainers. Of cource, with the assumption that all code base is version controlled.


答:
These days I don't have much problems reading other people's code. I've seen so much bad code, that I can even diagnose what sort of evolution led to any I find.

More often than not, professionally bad code is code that started out okay, but best practices, requirements, or skillsets moved out from underneath it. Sometimes it is just someone who is bad or new to the language, but that's pretty apparent too (and uncommon in a professional setting). The more I understand why code rots, the less I question the competence of other programmers.

Title: What happens to programmers most oftenly while reading the code of others?

Body:
When reading others code do you usually have any troubles understanding it,
 Or its more usually that you question the others code about it being wrong/non-efficient/bad-formatted(etc)?

Someone reading what you coded on your first job


答:
Let's assume A.B.C.D in the answers. When do you increase each of the components?

It is basically determined by your company policy. Our company policy is:

A - Significant (> 25%) changes or
additions in functionality or
interface.

B - small changes or
additions in functionality or
interface.

C - minor changes that
break the interface.

D - fixes to a
build that do not change the
interface.


问:
How do I know if a particular build has a particular version control change in it?
Let's say I have a build. I need to know if a particular changelist/commit is present in that build.

How would I solve this problem?

I can think of a couple of possible approaches:

1) Add the changelist number into the binary so that I can look somewhere in the GUI and know what the changelist number is. I can then use this information to determine if the change I'm interested in is within that build.

2) Tag version control using some string that uniquely identifies that build. What unique string would I use?

Is either of these two better? Are there any other better approaches?

The solution would have to work for both Mac and Windows builds.

答:
Most change control systems uniquely identity each modification/commit/check-in. For example, subversion has the revision ID and git has the commit hash. Either branch/tag for each release or record the commit identifier. Alternatively, keep track of a build number in the source code and search through the history/log for a release with that version number. With that, a developer can find the release in the source control system and look at commits preceding that to determine what changes are in a release.

Do not store the change list in the binary. This usually must be updated manually and, therefore, is prone to accidental omissions or copy and paste errors. The change list may also get large. How far back does the change list go? How much information is included in each change? Is it just an number of the issue from the issue tracking or change tracking system or is there more information? Lastly, putting this information in the binary may help an attacker find security vulnerabilities in the product.

Regarding what to tag, tag it with the version number of the release. If the release is a one off, like one containing a change specific to large customer, append the ID of the request in the support system or issue tracking system.

The operating system (Mac or Windows) is usually not relevant.


答:
This may be the result of this development process.

In the last 2 years I have working with other people code. I have debugged it, fixed bugs and made improvements. In my experience I usually think that the code is bad, full of bugs, slow, consumes much more memory than needed, used programming concepts inappropriately, really bad formatted (this is hard to live with), not commented and the logic flow is a mess. What if I tell you that I found one function with 5k lines of code?

So in my experience I usually question the quality of code. If something is hard to understand, because it is complex, it make sense after you understand it. But if it is just bad it will always be bad.


问:
Do any OO languages support a mechanism to guarantee an overriden method will call the base?
I think this might be a useful language feature and was wondering if any languages already support it.

The idea is if you have:

```<code>class C
  virtual F
     statement1
     statement2
</code>```

and

```<code>class D inherits C
  override F
     statement1
     statement2
     C.F()
</code>```

There would be a keyword applied to C.F() such that removing the last line of code above would cause a compiler error because it's saying "This method can be overridden but the implementation here needs to run no matter what".

答:
While not a bad idea in theory, it does have the negative side-effect of constraining my options when implementing D. For example, what if (for some unfathomable reason), it's more convenient to call the superclass implementation of F from some other method:

```<code>class D inherits C
    override F
        statement1
        statement2
        G()
    G
        statement3
        C.F()
        statement4
</code>```

Under your scenario, I imagine the compiler would flag the implementation of F in D, even though it does (indirectly) call C.F().

Basically, what you've described is a possible mechanism to help the compiler recognise when  a contract on classes inheriting from C is violated. My point is that, while that's a great thing, it shouldn't come at the expense of limiting how I can implement my subclass.

Body:
While not a bad idea in theory, it does have the negative side-effect of constraining my options when implementing D. For example, what if (for some unfathomable reason), it's more convenient to call the superclass implementation of F from some other method:

class D inherits C
    override F
        statement1
        statement2
        G()
    G
        statement3
        C.F()
        statement4

Under your scenario, I imagine the compiler would flag the implementation of F in D, even though it does (indirectly) call C.F().

Basically, what you've described is a possible mechanism to help the compiler recognise when  a contract on classes inheriting from C is violated. My point is that, while that's a great thing, it shouldn't come at the expense of limiting how I can implement my subclass.


问:
Finishing an iteration early
I'd like some input on this on those working with agile methodologies...

A current project is finding that development on our planned user stories is finishing some time before the end of the iteration, and that the testing effort and business acceptance is what's actually dragging us out longer towards the end. This means that the devs in question have spare time, and they're essentially going out to the iteration+1 backlog and starting work on cards there before our current iteration cards are 'done'. As iteration manager, I want to put a stop to this - I want a more team-orientated approach where the group takes ownership of getting all the cards done, as opposed to "Well, dev's done so what do I dev next?"

The problem I face is convincing the team of this. On one hand, I understand why the devs don't want to test the code they've written (there are unit tests they write of course, but the manual testing to be done could be influenced by their bias). The team sees working ahead as making our next iterations easier, because a lot of the work is done before we start. I see this as screwing with the whole system of planning/actuals - but it's difficult to convince the team as to why this matters.

What advice can you guys and girls give? How do we stop devs reaching ahead? What should they be doing instead? How much of a problem is this in the scheme of things, if things are still getting done?

答:
Are you sure you want to stop them from reaching ahead?  If you prevent developers from looking at (iteration+1), then in the next iteration they will take that much longer to accomplish their dev tasks. Which means your QA will have that much less time to test things.

On our team, a recurring theme is actually the opposite, developers tend to over-commit so they either don't get their tasks done or get them done right towards the end.  This has the effect of QA not having enough work in first 2/3 of iteration and way too much work at the end.

One of the ideas we've thrown around is to actually try to do what your team is already doing. Make developers take on less work and finish early so they can start looking at (iteration+1). This way some stories will get done earlier so that a) QA will not be bored in the beginning and overwhelmed at the end. Also in planning we would have better task estimates since people already had a chance to review the work ahead.

Being a developer and being a tester takes very different personalities and very different skill sets. I can see how most of your developers would be hesitant about jumping regularly into QA.  Not only would they simply not enjoy their jobs as much, but you will also not get the same quality out of a developer "forced" to test, rather than hiring one more QA person who actually enjoys what they do.

Just my opinion (and I am a developer)

Title: Finishing an iteration early


答:
This is usually caused by "failure", that is not delivering everything planned for the sprint, being seen as a negative thing by management. Remember the occasional failure is required to know exactly how much the team can deliver. You may also need to remind the team that their performance is partially judged on the amount of code they can deliver, not just whether they deliver the promised features in each sprint.

If that is not the case, why is the team finishing work early? For example:

Are they over estimating, a common problem with scrum? If so, use the "finished early" sprints as evidence to push the team a little harder.

Are they getting assistance from outside the team? If so, add these as workers.

Was time allocated to probable interruptions, such as supporting an existing product? If so, reduce the estimate for the next sprint.

Also ensure that supporting tasks are done in addition to the development work, including automated tests, ensuring the product installation/deployment is up to date, documentation is complete and so on. Consider raising the completion criteria for these. Alternatively, have the dev help the QA by creating test data, automating tests cases and so on.

Remember the sprint team is judged by sprint team effectiveness, not whether the devs finish their tasks early or not.

Title: Finishing an iteration early

Body:
I'd like some input on this on those working with agile methodologies...

A current project is finding that development on our planned user stories is finishing some time before the end of the iteration, and that the testing effort and business acceptance is what's actually dragging us out longer towards the end. This means that the devs in question have spare time, and they're essentially going out to the iteration+1 backlog and starting work on cards there before our current iteration cards are 'done'. As iteration manager, I want to put a stop to this - I want a more team-orientated approach where the group takes ownership of getting all the cards done, as opposed to "Well, dev's done so what do I dev next?"

The problem I face is convincing the team of this. On one hand, I understand why the devs don't want to test the code they've written (there are unit tests they write of course, but the manual testing to be done could be influenced by their bias). The team sees working ahead as making our next iterations easier, because a lot of the work is done before we start. I see this as screwing with the whole system of planning/actuals - but it's difficult to convince the team as to why this matters.

What advice can you guys and girls give? How do we stop devs reaching ahead? What should they be doing instead? How much of a problem is this in the scheme of things, if things are still getting done?


答:
The closest pattern I can think of is self-subscribed events.  It's a bit cumbersome, and not at all intuitive for the coder, but achieves the goal.</p>

```<code>class C
{
    public void F()
    {
        ...
        OnF()
    }

    protected event OnF
}

class D : C
{
    public D()
    {
        base.OnF += this.F
    }

    private void F
    {
        ...
    }
}
</code>```

Title: Do any OO languages support a mechanism to guarantee an overriden method will call the base?

Body:
I think this might be a useful language feature and was wondering if any languages already support it.

The idea is if you have:

```<code>class C
  virtual F
     statement1
     statement2
</code>```

and

```<code>class D inherits C
  override F
     statement1
     statement2
     C.F()
</code>```

There would be a keyword applied to C.F() such that removing the last line of code above would cause a compiler error because it's saying "This method can be overridden but the implementation here needs to run no matter what".

Body:
The closest pattern I can think of is self-subscribed events.  It's a bit cumbersome, and not at all intuitive for the coder, but achieves the goal.

class C
{
    public void F()
    {
        ...
        OnF()
    }

    protected event OnF
}

class D : C
{
    public D()
    {
        base.OnF += this.F
    }

    private void F
    {
        ...
    }
}


答:
No language I know of enforces calling the overridden method. Indeed, some languages allow overriding methods that are not overridable (such as using the new keyword in C#). However, there are two ways of approaching this.

The first is to create an unoverridable method (e.g. one that lacks the virtual keyword in C# or one that has the final keyword in Java) that calls an overridable one that cannot be called from outside the class (e.g. protected in C#, Java or C++).

```<code>class C
  A
     statement1
     F
     statement3

  protected virtual F
     statement2
</code>```

and

```<code>class D inherits C

  protected override F
     statement4
     C.F()
</code>```

Classes overriding C are free to override the F and modify its behavior but callers from outside the class only access it through A.

Edit: As others have pointed out, this is called the Template method pattern.

The second way is to use a language that enforces preconditions and postconditions specified in the base class, like Eiffel or C# with Code Contracts. It will not force the base class to be called but the overridden method can be forced to perform the same statements. Using aspects may also help if the language allows aspects to be inherited.

Body:
No language I know of enforces calling the overridden method. Indeed, some languages allow overriding methods that are not overridable (such as using the new keyword in C#). However, there are two ways of approaching this.

The first is to create an unoverridable method (e.g. one that lacks the virtual keyword in C# or one that has the final keyword in Java) that calls an overridable one that cannot be called from outside the class (e.g. protected in C#, Java or C++).

class C
  A
     statement1
     F
     statement3

  protected virtual F
     statement2

and

class D inherits C

  protected override F
     statement4
     C.F()

Classes overriding C are free to override the F and modify its behavior but callers from outside the class only access it through A.

Edit: As others have pointed out, this is called the Template method pattern.

The second way is to use a language that enforces preconditions and postconditions specified in the base class, like Eiffel or C# with Code Contracts. It will not force the base class to be called but the overridden method can be forced to perform the same statements. Using aspects may also help if the language allows aspects to be inherited.


答:
Why is the testing effort and business acceptance taking so long?

It sounds to me like you're planning mini-waterfall projects within your iterations (developing, then testing, then acceptance). Testing and accepting should be done directly after each user story is finished, and preferably by the people who developed it plus a product owner.  It should not take longer than one, maybe two hours (if you streamline this it could be done in minutes).

There are some solutions for now.  You can have the development team research new technologies one day in the week to keep them busy. In this day it might be a good idea for them to look into their testing processes, since they seem to have a problem with testing (they don't like it). Perhaps they can spend their extra time developing an automated test environment that goes beyond some simple unit tests (unit testing is just one of a multitude of testing techniques).

Title: Finishing an iteration early


答:
We don't do this in my current company, and I can't really say that I've missed this feature, but in my previous company we did your option (1) by adding to every source file:

```<code>static const char* fileId = "$Id: $";
</code>```

Most revision control systems support some kind of form of tags that automatically get filled in when the file is checked in, so as soon as the file would get into source control, that tag would automatically be changed to:

```<code>static const char* fileId = "$Id: Utility.cpp; rev 6; last check-in 5/2/2012 by so-and-so $";
</code>```

The format of the string is made up as I don't really remember what it looked like, but you get the idea.  When a binary was built from these source files, you could always run

```<code>strings app_name | grep Utility.cpp
</code>```

This would give you the exact revision of Utility.cpp that went into building that binary.  (It's also been 8 years since I touched unix command line, so please don't hold it against me if I didn't get the command line exactly right, the idea is there).

While we could certainly do it in the company I work for now, I think we never had the need for this technique simply because once you get a stable and reliable build process going, you can simply take a look at the version number of the binary and you know exactly which file revisions went into making that.

Title: How do I know if a particular build has a particular version control change in it?

Body:
Let's say I have a build. I need to know if a particular changelist/commit is present in that build.

How would I solve this problem?

I can think of a couple of possible approaches:

1) Add the changelist number into the binary so that I can look somewhere in the GUI and know what the changelist number is. I can then use this information to determine if the change I'm interested in is within that build.

2) Tag version control using some string that uniquely identifies that build. What unique string would I use?

Is either of these two better? Are there any other better approaches?

The solution would have to work for both Mac and Windows builds.

Body:
We don't do this in my current company, and I can't really say that I've missed this feature, but in my previous company we did your option (1) by adding to every source file:

static const char* fileId = "$Id: $";

Most revision control systems support some kind of form of tags that automatically get filled in when the file is checked in, so as soon as the file would get into source control, that tag would automatically be changed to:

static const char* fileId = "$Id: Utility.cpp; rev 6; last check-in 5/2/2012 by so-and-so $";

The format of the string is made up as I don't really remember what it looked like, but you get the idea.  When a binary was built from these source files, you could always run

strings app_name | grep Utility.cpp

This would give you the exact revision of Utility.cpp that went into building that binary.  (It's also been 8 years since I touched unix command line, so please don't hold it against me if I didn't get the command line exactly right, the idea is there).

While we could certainly do it in the company I work for now, I think we never had the need for this technique simply because once you get a stable and reliable build process going, you can simply take a look at the version number of the binary and you know exactly which file revisions went into making that.


答:
If you think no management is needed, who will perform the following organizational jobs, who will respond in the following situations?

new clients must be found. How do you sell your products? How do you advertise?

materials must be purchased, suppliers must be found

diplomatic discussions with other companies, or banks, or a government office must be led

Title: Does a mature agile team requires any management?

Body:
After a recent heated debate over Scrum, I realized my problem is that I think of management as a quite unnecessary and redundant activity in a fully agile team. I believe a mature Agile team does not require management or any non-technical decision making process whatsoever. To my (apparently erring) eyes it is more than obvious that the only one suitable and capable of managing a mature development team is their coach (who is the most technically competent colleague with proper communication skills). I can't imagine how a Scrum master can contribute to such a team.

I am having great difficulty realizing and understanding the value of such things in Scrum and the manager as someone who is not a veteran developer but is well skilled in planning the production cycles when a coach exists in the team. What does that even mean? How on earth can someone with no edge-skills of development manage a highly technical team? Perhaps management here means something else?

I see management as a total waste of time and a by-product of immaturity. In my understanding a mature team is fully self-managing. Apparently I'm mistaken since many great people say the contrary but I can't convince myself.


问:
What would you think of a job based on mostly doing the proof of concept?
I'm working as a developer in a small software company whose main job is interfacing between separate applications, like between a telephony system and an environment control system, between IP TVs and hospitality systems, etc...And it seems like I am the candidate for a new job title in the company, as the person who does the proof of concept of a new interfacing project and does some R&D for prototyping.

What do you think the pros and cons of such a job would be, considering mainly the individual progress/regress of a person as a software engineer? And what aspects would you consider essential in a person to put him/her in such a job position?

答:
Since I've worked with someone who has done this and seen the impacts on the quality of the work of his that gets passed around I'd worry more about the perceptions of those who inherit my work.  Things that are prototyped often do not need to worry about corner cases or are done in a manner which is more concerned with schedule at all costs than maintainability.

You'd have to guard against three things:

A gradual degradation of your own default code quality.

The "if-I-can-say-it-it-can-be-done" work which might get thrown at you.  The schedule could be awfully filled with hope.  They'd be looking at you going "it doesn't have to be perfect, just get it done" when in fact, just getting it to a prototype level requires a LOT of work.

The converse, "I-can-do-it-for-just-this-case-but-it-can't-be-generalized."  This one is more subtle as people often don't think past very specific pieces of code or datasets.  I've been handed way too many things which can't scale and the prototype never even needed to address the issue.

ContentLicense: CC BY-SA 2.5


答:
There is no next build. On that branch.

Idealized version of our scheme.

Version identification on any branch is PRETTY_BRANCH_NAME-build and PRETTY_BRANCH_NAME is fixed at branch creation.

Our branching scheme(*) is the following:

Top level branches, the PRETTY_BRANCH_NAME of each is a code name, speaking of version number at that level is meaningless, there may be a planned scheme but it will change before the release.

a TNG (the next generation) branch where long term development is made. Often we don't even have it and it has never (release) subbranches.

a TCG (the current generation) branch where current development is made. PRETTY_BRANCH_NAME is a code name.

a TPG (the previous generation) branch. Often no more development is made here, but there may be activity in the subbranches.

A subbranch is made of a top level branch (of TCG, in presence of slow migration of TPG) when beta for a major release start. The PRETTY_BRANCH_NAME is something like "1.3.X" (X is the letter, not the digit, it means we intend to deliver 1.3 releases from here), feedback from beta is token into account here while work for the next major release is done on the TCG branch.

Ideally, release should be snapshot on that branch, but we know we aren't perfect and often need to do last minute changes while allowing others to continue to work for the next minor release. Thus subsubbranches are made for the final stabilization with pretty names being the official version number (at that time even marketing won't want to change it) like "1.3", "1.3.1" out of the "1.3.X" branch, the last build on each is the release.

If we had a fourth level, the subsubbranches names would have been "1.3.0.X" out of which we'd have had sub^3branches "1.3.0.0" "1.3.0.1".

(*) At the release level. There may be project subbranches on each of these.


答:
2) Tag version control using some string that uniquely identifies that
  build. What unique string would I use?

Are you using a bug tracking system ?

If not I suggest JIRA or Mantis (I prefer JIRA personally, but I also worked with Mantis before and although not as pretty as JIRA it was fine)

Whether it is a bug, or an evolution, the developer(s) should have a bug ticket assigned. The bug ticket has a unique name (say PROJECTX-234). Notify all developers that their comment must contain the name of the ticket the modification relates to. Doing so will allow you to retrieve in your source repository anything that is related to a given change in your application. Searching with the help of the comments should lead to a list that looks like that:

```<code> PROJECTX-234 first commit
 PROJECTX-234 yyy
 ...
 PROJECTX-234 xxx
</code>```

Also, JIRA itself, and several continuous build tools (such as Jenkins for example) may connect directly to your repository so that any bug ticket is "linked" to the code that has been changed in order to resolve it.

I don't what your build tool is, but for example Jenkins will list for a given build or release the changes that occurred. Moreover, if you add the JIRA plugin to it, Jenkins may write a comment directly in the bug ticket to indicate in which build the bug has been resolved.

Finally, if you don't want to work with a bug tracking system, write a simple Excel file with the tasks you have to perform and choose a unique name for each one. Use that unique name in your commits.

Body:
2) Tag version control using some string that uniquely identifies that
  build. What unique string would I use?

Are you using a bug tracking system ?

If not I suggest JIRA or Mantis (I prefer JIRA personally, but I also worked with Mantis before and although not as pretty as JIRA it was fine)

Whether it is a bug, or an evolution, the developer(s) should have a bug ticket assigned. The bug ticket has a unique name (say PROJECTX-234). Notify all developers that their comment must contain the name of the ticket the modification relates to. Doing so will allow you to retrieve in your source repository anything that is related to a given change in your application. Searching with the help of the comments should lead to a list that looks like that:

 PROJECTX-234 first commit
 PROJECTX-234 yyy
 ...
 PROJECTX-234 xxx

Also, JIRA itself, and several continuous build tools (such as Jenkins for example) may connect directly to your repository so that any bug ticket is "linked" to the code that has been changed in order to resolve it.

I don't what your build tool is, but for example Jenkins will list for a given build or release the changes that occurred. Moreover, if you add the JIRA plugin to it, Jenkins may write a comment directly in the bug ticket to indicate in which build the bug has been resolved.

Finally, if you don't want to work with a bug tracking system, write a simple Excel file with the tasks you have to perform and choose a unique name for each one. Use that unique name in your commits.


问:
How can I improve these online java programming puzzles I wrote for my (middle/high school) students?
I'm teaching some middle and high school students programming right now, and I found that some of them really liked online programming puzzles. So I created http://www.kapparate.com/coder/ , and right now there's 4 categories of puzzles.

All the puzzles are set up right now so that variables are pre-initialized, and the user plugs in some code in the middle.

For example, the problem might say these are pre-initialized:

```<code>int x = ????;
int y = ????;
int z;
</code>```

and then the program might ask the student to write the final line of code: z = x + y;.

Now I know I could go a long way in improving the usability of this site (like having an area that lists the pre-defined variables), but I was wondering if this concept seems sound. I know some sites have kids fill in functions, but not all of my students know what functions are yet, and I'm trying to introduce online programming puzzles before that.

答:
There was a site a while ago (it is dead now) called codingkata.org. The Java katas on there had a problem description and then you used a maven archetype to get the project and implement the given method signatures. There were then unit tests that ran over your code when you ran mvn test that told you whether you passed the kata or not.

Doing something like this would introduce your students to the concepts of maven (which is used heavily in the Java world) and get them used to using it to setup projects, manage the pom and run unit tests.

It would also force them into learning about functions and going from this is my problem to this is my solution all within the safety of knowing that it can be automatically checked.

They can also use their favourite IDE/text-editor/etc. to implement the code as they see fit too.

I would also work on the description of your problems too; I found them hard to read personally.


问:
How do I translate user input into a fictitious language?
For experimental reasons, I am trying to convert user input into a fictitious language. All of the translation can be 1:1.

I would prefer if I could accomplish this with PHP.

Should I use gettext and poedit? The fictitious language is not very large, I imagine I can do most of the translation 1:1

I have scoured the googles, but have only found dated code and localization.

答:
gettext is the wrong tool for that job. It is intended to translate a potentially large but finite well-defined set of pre-formulated messages, possibly with variable insertions, between languages. User input in natural language is not such a set. You are better off defining the transformations you need to make in general terms and apply them to the input you get, e.g. as a set of regex transformations stored in a map of from-to pairs. That is easily done in PHP.

But note that there will almost certainly be things that you cannot achieve with such simple replacements. "you all" may usually be transform to "y'all", but what about "Let me show you all our biggest sellers"? Depending on how convincing you need the result to be, the task may be stupendously more difficult than it appears at first sight. Natural language translation, even if it's only a "dialect", is a T. Rex in sheep's clothing.


答: Not really part of the language, but the FindBugs static code analyzer for Java has an annotation OverrideMustInvoke that a developer can add to a method, and which will cause FindBugs to show an error if it finds an overriding method that doesn't call the super implementation. It even allows specifying whether the call must be first or last in the overriding method.


问:
design pattern advice: graph -> computation
I have a domain model, persisted in a database, which represents a graph. A graph consists of nodes (e.g. NodeTypeA, NodeTypeB) which are connected via branches. The two generic elements (nodes and branches will have properties). A graph will be sent to a computation engine. To perform computations the engine has to be initialised like so (simplified pseudo code):

```<code>Engine Engine = new Engine() ;
Object ID1 = Engine.AddNodeTypeA(TypeA.Property1, TypeA.Property2, …, TypeA.Propertyn);
Object ID2 = Engine.AddNodeTypeB(TypeB.Property1, TypeB.Property2, …, TypeB.Propertyn);
Engine.AddBranch(ID1,ID2);
</code>```

Finally the computation is performed like this:

```<code>Engine.DoSomeComputation();
</code>```

I am just wondering, if there are any relevant design patterns out there, which help to achieve the above using good design principles. I hope this makes sense. Any feedback would be very much appreciated.

答:
I think the Visitor Pattern is appropriate to your problem, as it allows you to separate the tasks:

apply a computation to every node on the graph; and

the computation that is applied.

Your DoSomeComputation() method would take a parameter that is a (closure/lambda/implementation of some Visitor interface[*]) and apply that to the nodes on the graph.

[*] delete as appropriate for the programming language you're using.


问:
JavaFX 2.0 vs Qt for cross platform stand-alone application
I need a bit of advice from you developers who deal with cross-platform applications (specifically programs with a GUI).

I will be creating an application soon that needs to be cross-platform and so I have done some preliminary research on two different frameworks: JavaFX 2.0 and Qt.

Honestly, both would more than suit my needs.  So then I asked myself why I would choose one over the other (SPOILER ALERT: I don't know the answer :P ).  I do know that JavaFX 2.0 is rather new (as of 2012) and is not fully supported across platforms, but it will be eventually.

The question I pose is this: which one of these would you use for a cross-platform application, and what criteria did you look at when making that decision?

Thank you for taking the time to read this!  :)

答:
So we did an analysis of the two (+ HTML 5) for our purposes and found that JavaFX narrowly won out due to our familiarity with Java and Java based tooling and support stacks.

Our methodology was to list 20 criteria and rank each technology out of 10 for each.

For example, i18n, ease of hiring, x-platform support, mobile support, strength of commnuity, depth of tooling etc


答:
I did this for a chat program once.  You dont need a toolkit.  Just parse the text thats entered (ie, separate by spaces) and keep the words in an array.  Then start working through them, looking at the words and any subsequent words.  Match the sequences with your dialect/slang, and for any match, do the substitution.  So as you work through the words, you'd build the output string either from the original word, or from any substitutions you found.

Might help to maintain two arrays - one that maintains the case and punctuation, and the other that converts text to lower case to make your checks against the dictionary simpler.  Make sure their array indexes match.  This way when you dont find a match in the array with lower case text, you can output the original, unmodified text.

For the dictionary, in PHP, you can take advantage of its arrays - perhaps build it like $words['find'] = 'replace'.  Or for multi-word sequences, make it a nested array.

That should get you a decent first pass at a translator.  You'll probaby then have to consider how to handle things like "text in quotes" and other punctuation.

Title: How do I translate user input into a fictitious language?

Body:
For experimental reasons, I am trying to convert user input into a fictitious language. All of the translation can be 1:1.

I would prefer if I could accomplish this with PHP.

Should I use gettext and poedit? The fictitious language is not very large, I imagine I can do most of the translation 1:1

I have scoured the googles, but have only found dated code and localization.


问:
Equivalent of SOLID principles for functional programming
I've found the SOLID principles quite useful when thinking about object-oriented design.

Is there a similar / equivalent set of language-agnostic principles tailored for functional programming?

答:
It is a bit difficult to find equivalents but I can try:

S (SRP) in FP a function creates ALWAYS the same output for the same arguments this is called referential transparency

O (OCP) in FP there is a concept called algebraic data types, have a look how it relates to Class hierarchies and what problem both try to solve 1

L (LSP) Liskov Substitution Principle is Contravariance 2

D (DIP) in general functional programming achieves abstraction through function composition, there are also other mechanism with the help of category theory(for example monoid or functor), for "Dependency Injection" 3


问:
What is use of universal character names in identifiers in C++
The C++ standard (I noticed it in the new one, but it did already exist in C++03) specifies universal character names, written as \uNNNN and \UNNNNNNNN and representing the characters with unicode codepoints NNNN/NNNNNNNN. This is useful with string literals, especially since explicitly UTF-8, UTF-16 and UCS-4 string literals are also defined. However, the universal character literals are also allowed in identifiers. What is the motivation behind that?

The syntax is obviously totally unreadable, the identifiers may be mangled for the linker and it's not like there was any standard function to retrieve symbols by name anyway. So why would anybody actually use an identifier with universal character literals in it?

Edit: Since it actually existed in C++03 already, additional question would be whether you actually saw a code that used it?

答: It allows a system allowing unicode characters in identifier to export the source in a format compilable on any standard conforming compilers. I.E. it is a way to encode unicode over the basic character set (more or less like quoted-printable is used for email, systems who knows better are able to do a better job, other systems are still working).</p>


问:
Advantages of using pure JavaScript over JQuery
What are the advantages of using Javascript-only versus using JQuery-only?

I have limited experience with JavaScript and JQuery coding. I've added bits and snippets of each to HTML pages but I've mostly coded server-side stuff in other languages. I've noticed that while you can theoretically do the same things using either of the two approaches (and of course you can even mix 'em up in the same project) there seems to be a tendency to always start using JQuery from the very beginning no-matter what the project demands are.

So I'm simply wondering, are there any punctual benefits to not use JQuery-only but instead to just use plain old JavaScript?

I know this looks like a non-question because it can be said about it that "there's no definite answer" or "it can be debated for ever", but I'm actually hoping for punctual answers such as "You can do this in one approach and you cannot do it with the other".

As per scrwtp's comment, I'm not referring just to the DOM Handling part. My question is rather: JQuery is a library. For Javascript. What I find strange about this library as opposed to other libraries for other languages is that in JQyery's case it seems to be designed to be able to use it exclusively and not need to touch Javascript directly. This is as opposed to let's say Hibernate and SQL, where even though the library (or rather framework in this case, but I think the analogy still applies) takes the handle on A LOT of aspects, you still get to use SQL when using it, at least for some fringe cases. However in JQuery & Javascript case, you could do anything you do with Javascript using only JQuery (or at least that's how it seems to me).

As per Stargazer712's comment: yes, I agree with you, the question here is, as you put it "just a matter of how you will be using JavaScript". That's what I was actually thriving to ask, but I've made some bad formulations. Here's another analogy: Spring Expression Language. It's a Java library. You can't use it without Java, it's based on Java, and down through it all you still get to use Java. But in practice what you can do is add this library to a Java project, and then write all your code using Spring EL's expression language which effectively makes your code not resemble Java at all, and it's even paradigm shifting (for example you no longer have strong type enforcement when using this). While I do understand that JQuery is just a JS library, to me it seems that in practice it has the same effect as Spring EL has with Java, i.e you can only use it's APIs through out a project and avoid JavaScript's APIs. And I was wondering if that's a good thing to do, what might be the pitfalls etc.

(and yes, after reading everyone's answers I do understand that :

a. my question is somewhat non-sensical up to a point

b. even if the question were completly accurate, the answer to it would be pretty much "no you can't just use JQuery-only all the time)

答:
There are advantages, but it's debatable whether they really outweigh the drawbacks.

The main one is that you save bandwidth and gain faster responses. jQuery adds another ~30kb to your response. On some networks (and in some countries), that could mean a few more milliseconds. On the other hand, though, you can set up caching for it rather easily using your web server (or as Xion said, use it from Google's site so it won't impact your own, and still be cached).

The second thing is that you might only need some very simple functionality, and only downloading and setting jQuery up could take more time than simply implementing what you need.

And lastly, you might want to roll your own framework, which is mostly a bad idea, but some people have their reasons.

If however you discard jQuery simply because you're intimidated by the learning curve, then you should reconsider. Especially as it as rather gentle.


答:
Yes, they do. It is called Scandinavian model of OO, it is used for example in Simula (the other OO model which is widespread and taken as granted now, is American model). In Scandinavian model, you are not overriding, but supplying sub-behaviour.

in Superclass's method foo:

```<code>some-code-before
INNER // this is the actual Simula keyword
some-code-after
</code>```

in Subclass' method foo:

```<code>some-code-in-subclass
</code>```

If you call Superclass' instances' method foo, only some-code-before and some-code-after happens (INNER does nothing), but if you call Subclass' instances' foo, it does some-code-before, some-code-in-subclass and then some-code-after.

Body:
Yes, they do. It is called Scandinavian model of OO, it is used for example in Simula (the other OO model which is widespread and taken as granted now, is American model). In Scandinavian model, you are not overriding, but supplying sub-behaviour.

in Superclass's method foo:

some-code-before
INNER // this is the actual Simula keyword
some-code-after

in Subclass' method foo:

some-code-in-subclass

If you call Superclass' instances' method foo, only some-code-before and some-code-after happens (INNER does nothing), but if you call Subclass' instances' foo, it does some-code-before, some-code-in-subclass and then some-code-after.


答: I think the most important question, is how important is this position to your company's core business? If this work is a fundamental part of taking on new business then that is pretty attractive. If the value connection is a little vague then I'd steer clear of it myself.</p>

Title: What would you think of a job based on mostly doing the proof of concept?

Body:
I'm working as a developer in a small software company whose main job is interfacing between separate applications, like between a telephony system and an environment control system, between IP TVs and hospitality systems, etc...And it seems like I am the candidate for a new job title in the company, as the person who does the proof of concept of a new interfacing project and does some R&D for prototyping.

What do you think the pros and cons of such a job would be, considering mainly the individual progress/regress of a person as a software engineer? And what aspects would you consider essential in a person to put him/her in such a job position?


答:
After you release your software, the version number should be incremented immediately.

Why?

Let's assume you're following a scheme like Semantic Versioning, and you have a build number in the version. So you might have [Major].[Minor].[Patch].[Build]. I am going to call the [Major].[Minor].[Patch] part the version.

You will be creating multiple builds during development. Each build is a development snapshot of your next release. It makes sense to use the same version for your development and release builds. The version indicates what release you're working toward.

If you're preparing for release and the software passes all of its tests, you won't want to rebuild and retest the software just because you had to update the version. When you eventually make a release, you are stating that "build 1.1.0.23" shall henceforth be referred to as "version 1.1.0".

The increment-after-release model makes sense for branching too. Suppose you have a mainline development branch, and you create maintenance branches for releases. The moment you create your release branch, your development branch is no longer linked to that release's version number. The development branch contains code that is part of the next release, so the version should reflect that.


答:
Requiring to call a superclass method is an anti-pattern. If it isn't enforced at compile time it is error-prone, which is why you are looking for a language construct that checks for it.

There is a way that is supported in all OO languages: The template method pattern. Here, you make the superclass method not overridable, and in it you call a overridable method. The subclass then can override this method to add functionality:

```<code>class super {
  public final void doSomething() {
    doSpecialthing();
    doMore();
  }
  public void doSpecialthing() {
  }
}
</code>```

Depending on the location of the call to the overridden method it even allows to determine the order of execution, which with the ordinary super call is at will of the subclass implementer.

Body:
Requiring to call a superclass method is an anti-pattern. If it isn't enforced at compile time it is error-prone, which is why you are looking for a language construct that checks for it.

There is a way that is supported in all OO languages: The template method pattern. Here, you make the superclass method not overridable, and in it you call a overridable method. The subclass then can override this method to add functionality:

class super {
  public final void doSomething() {
    doSpecialthing();
    doMore();
  }
  public void doSpecialthing() {
  }
}

Depending on the location of the call to the overridden method it even allows to determine the order of execution, which with the ordinary super call is at will of the subclass implementer.


问:
Floating point undesirable in highly critical code?
Question 11 in the Software Quality section of "IEEE Computer Society Real-World Software Engineering Problems", Naveda, Seidman, lists fp computation as undesirable because "the accuracy of the computations cannot be guaranteed".

This is in the context of computing acceleration for an emergency braking system for a high speed train. This thinking seems to be invoking possible errors in small differences between measurements of a moving object but small differences at slow speeds aren't a problem (or shouldn't be), small differences between two measurements at high speed are irrelevant - can there be a problem with small roundoff errors during deceleration for an emergency braking system? This problem has been observed with airplane braking systems resulting in hydroplaning but could this actually happen in the context of a high speed train?  The concern about fp errors seems to not be well-founded in this context. Any insight? The fp is used for acceleration so perhaps the concern is inching over a speed limit? But fp should be just fine if they use a double in whatever implementation language.

The actual problem in the text states: During the inspection of the code for the emergency braking system of a new high speed train (a highly critical, real-time application), the review team identifies several characteristics of the code. Which of these characteristics are generally viewed as undesirable?

The code contains three recursive functions (well that one is obvious).

The computation of acceleration uses floating point arithmetic.

All other computations use integer arithmetic.

The code contains one linked list that uses dynamic memory allocation (second obvious problem).

All inputs are checked to determine that they are within expected bounds before they are used.

答: Floating-point is generally undesirable in hard-real-time applications both due to accumulation of error and the fact that FP computation is typically slower than integer arithmetic.  Then you also have the overhead with promoting integers to floating point (or vice versa) for comparison if you're mixing the two.  And since you can't simply compare a floating-point number to zero, you turn a simple statement like if(x == 0) into if(x > -0.0001 && x < 0.001) -- you've gone from one simple comparison to two comparisons and a logical operation.  Not what you want to be wasting cycles on when people's lives are on the line.


答:
The only thing I can think of that you can't do without JQuery would be to use JQuery plugins; even then, you could write your own JS library that would provide just what the plugin needs.

Think about it like this: JQuery is an open-source Javascript library written in Javascript; you can look at the source, and thereby learn how to do anything that it does.

You can't use JQuery without using plain old Javascript. You probably won't use document.getElementById, but you'll still define functions and variables in the standard Javascript ways; you might even write a standard for loop.

The main benefit to using JQuery is pretty much the same as any other 3rd party library in any language: you won't have to write as much code to implement the logic specific to your application.

Don't let the size scare you away. The CDN version is a ~33k download which will be cached by the user's browser after the first page hit.

Title: Advantages of using pure JavaScript over JQuery

Body:
What are the advantages of using Javascript-only versus using JQuery-only?

I have limited experience with JavaScript and JQuery coding. I've added bits and snippets of each to HTML pages but I've mostly coded server-side stuff in other languages. I've noticed that while you can theoretically do the same things using either of the two approaches (and of course you can even mix 'em up in the same project) there seems to be a tendency to always start using JQuery from the very beginning no-matter what the project demands are.

So I'm simply wondering, are there any punctual benefits to not use JQuery-only but instead to just use plain old JavaScript?

I know this looks like a non-question because it can be said about it that "there's no definite answer" or "it can be debated for ever", but I'm actually hoping for punctual answers such as "You can do this in one approach and you cannot do it with the other".

As per scrwtp's comment, I'm not referring just to the DOM Handling part. My question is rather: JQuery is a library. For Javascript. What I find strange about this library as opposed to other libraries for other languages is that in JQyery's case it seems to be designed to be able to use it exclusively and not need to touch Javascript directly. This is as opposed to let's say Hibernate and SQL, where even though the library (or rather framework in this case, but I think the analogy still applies) takes the handle on A LOT of aspects, you still get to use SQL when using it, at least for some fringe cases. However in JQuery & Javascript case, you could do anything you do with Javascript using only JQuery (or at least that's how it seems to me).

As per Stargazer712's comment: yes, I agree with you, the question here is, as you put it "just a matter of how you will be using JavaScript". That's what I was actually thriving to ask, but I've made some bad formulations. Here's another analogy: Spring Expression Language. It's a Java library. You can't use it without Java, it's based on Java, and down through it all you still get to use Java. But in practice what you can do is add this library to a Java project, and then write all your code using Spring EL's expression language which effectively makes your code not resemble Java at all, and it's even paradigm shifting (for example you no longer have strong type enforcement when using this). While I do understand that JQuery is just a JS library, to me it seems that in practice it has the same effect as Spring EL has with Java, i.e you can only use it's APIs through out a project and avoid JavaScript's APIs. And I was wondering if that's a good thing to do, what might be the pitfalls etc.

(and yes, after reading everyone's answers I do understand that :

a. my question is somewhat non-sensical up to a point

b. even if the question were completly accurate, the answer to it would be pretty much "no you can't just use JQuery-only all the time)


答:
As far as I know there are really only two advantages of using vanilla javascript versus a library such as JQuery, MooTools, etc.

Libraries have a payload that eats bandwidth. But as people already have pointed out in the other answers you can limit this with gzipping and caching. If you only want a subset of jQuery you can do with SizzleJS and with MooTools you have the option of selecting the feature sets that you want in the same way as what Modernizr does.

Libraries are big and takes some time to learn. Then again, this is a one-time investment for developers... and it looks nice on your resumé to know javascript libraries.

(BONUS) Libraries are not a silver bullet so if you like to reinvent the wheel then this is definitely way to go.

It is worth pointing out why you want to use a javascript library, for which there are plenty:

You don't need to write your own framework to support your development. If you're curious how things work you can check out the code since it is open source.

The libraries solves browser compatibility. Both DOM and javascript have some differences between browsers. Trust me, this is a huge time sink if you have to hack fixes yourself.

It is de facto internet standard to use javascript libraries, most of them are well documented by now and most web developers (who know javascript) know how to use them.

You don't really give up javascript when using a library. You still need to know Javascript with it's types, objects, how closures work, etc.

Most libraries are modularized and it doesn't take a long time to write plugins or use require and the AMD pattern.

CSS selecting elements from the DOM is a huge help.

(BONUS) You can use them with CoffeeScript as well.

I used to work at a web shop that was adamant on using vanilla javascript because jQuery was big and scary. This decision, mostly influenced by a lone "javascript developer", was the source of many browser bugs and slow development and trying to get into his codebase was a hair-pulling experience. Writing your own framework might seem like a good idea, but if you want to hire new developers then they can't quickly hop in and help out. Then there is also the issue of the bus factor to consider.

As I said I used to work there... there were greener pastures elsewhere. :^)


答:
The problem with floating point code is that it doesn't behave like pen-and-paper decimal arithmetic calculations. This leads people who haven't taken the time to understand what is going on to make incorrect assumptions about the behavior of floating point numbers, which can then lead to incorrect program behavior. The behavior of FP calculations with very large and very small numbers can be quite un-intuitive, especially if you mix the two.

IF your team understands floating point numbers and how they work, and IF your system's design doesn't include anything that will trip up FP calculations, then there is no inherent reason not to use them.

In a lot of cases it's FAR easier to just put a blanket prohibition on FP, rather than try to insure that everyone understands what they are doing and that the numbers can't get away from you in unexpected ways. The review team also may find it easier to verify that you're doing the conversions and calculations correctly in integer rather than FP, because it's easier to see where you'll lose precision.

Title: Floating point undesirable in highly critical code?

Body:
Question 11 in the Software Quality section of "IEEE Computer Society Real-World Software Engineering Problems", Naveda, Seidman, lists fp computation as undesirable because "the accuracy of the computations cannot be guaranteed".

This is in the context of computing acceleration for an emergency braking system for a high speed train. This thinking seems to be invoking possible errors in small differences between measurements of a moving object but small differences at slow speeds aren't a problem (or shouldn't be), small differences between two measurements at high speed are irrelevant - can there be a problem with small roundoff errors during deceleration for an emergency braking system? This problem has been observed with airplane braking systems resulting in hydroplaning but could this actually happen in the context of a high speed train?  The concern about fp errors seems to not be well-founded in this context. Any insight? The fp is used for acceleration so perhaps the concern is inching over a speed limit? But fp should be just fine if they use a double in whatever implementation language.

The actual problem in the text states: During the inspection of the code for the emergency braking system of a new high speed train (a highly critical, real-time application), the review team identifies several characteristics of the code. Which of these characteristics are generally viewed as undesirable?

The code contains three recursive functions (well that one is obvious).

The computation of acceleration uses floating point arithmetic.

All other computations use integer arithmetic.

The code contains one linked list that uses dynamic memory allocation (second obvious problem).

All inputs are checked to determine that they are within expected bounds before they are used.


答:
You are looking for something like this chef/jive/val/pig translator (there is c/lex source there).

The piglatin translator works through each word and reorders the characters.

The jive and val translators identify certain entire words and replaces them with alternate entire words (with some randomization tossed in at times).

http://www.ibm.com/developerworks/linux/library/l-perl-parsing/ works on translating a lex grammar into perl (and incidentally, works on the chef.l file from the first link).  It links the perl source for a completed translation which may be of use for a php programmer.


问:
Generic Adjacency List Graph implementation
I am trying to come up with a decent Adjacency List graph implementation so I can start tooling around with all kinds of graph problems and algorithms like traveling salesman and other problems...  But I can't seem to come up with a decent implementation.  This is probably because I am trying to dust the cobwebs off my data structures class.

But what I have so far... and this is implemented in Java... is basically an edgeNode class that has a generic type and a weight-in the event the graph is indeed weighted.

```<code>public class edgeNode<E> {
    private E y;
    private int weight;

    //... getters and setters as well as constructors...
}
</code>```

I have a graph class that has a list of edges a value for the number of Vertices and and an int value for edges as well as a boolean value for whether or not it is directed.  The brings up my first question, if the graph is indeed directed, shouldn't I have a value in my edgeNode class?  Or would I just need to add another vertices to my LinkedList?  That would imply that a directed graph is 2X as big as an undirected graph wouldn't it?

```<code>public class graph {
    private List<edgeNode<?>> edges;
    private int nVertices;
    private int nEdges;
    private boolean directed;

    //... getters and setters as well as constructors...
}
</code>```

Finally does anybody have a standard way of initializing there graph?  I was thinking of reading in a pipe-delimited file but that is so 1997.

```<code>public graph GenereateGraph(boolean directed, String file){
        List<edgeNode<?>> edges;
        graph g;
        try{
            int count = 0;
            String line;
            FileReader input = new FileReader("C:\\Users\\derekww\\Documents\\JavaEE Projects\\graphFile");
            BufferedReader bufRead = new BufferedReader(input);
            line = bufRead.readLine();
            count++;
            edges = new ArrayList<edgeNode<?>>();
            while(line != null){
                line = bufRead.readLine();
                Object edgeInfo = line.split("|")[0];
                int weight = Integer.parseInt(line.split("|")[1]);
                edgeNode<String> e = new edgeNode<String>((String)
                edges.add(e);
            }
            return g;
        }
        catch(Exception e){
            return null;
        }
    }
</code>```

I guess when I am adding edges if boolean is true I would be adding a second edge.  So far, this all depends on the file I write.  So if I wrote a file with the following Vertices and weights...

```<code>Buffalo | 18  br Pittsburgh | 20 br New York | 15 br D.C | 45 br
</code>```

I would obviously load them into my list of edges, but how can I represent one vertices connected to the other... so on... I would need the opposite vertices?  Say I was representing Highways connected to each city weighted and un-directed (each edge is bi-directional with weights in some fictional distance unit)... Would my implementation be the best way to do that?

I found this tutorial online Graph Tutorial that has a connector object.  This appears to me be a collection of vertices pointing to each other.  So you would have A and B each with there weights and so on, and you would add this to a list and this list of connectors to your graph... That strikes me as somewhat cumbersome and a little dismissive of the adjacency list concept?  Am I wrong and that is a novel solution?

This is all inspired by steve skiena's Algorithm Design Manual.  Which I have to say is pretty good so far.  Thanks for any help you can provide.

答:
Here is something I dug up.  If anyone has a better implementation I will mark his remark as the answer...

```<code>public interface AdjList {
    int beg();
    int nxt();
    boolean end();
}

public class Edge {
    int v, w;
    //E value;
    Edge(int v, int w){
        this.v = v;
        this.w=w;
    }
}

public class GraphAdjList implements IGraph{
    private int vertCount, EdgeCount;

    private boolean directedGrph;

    private class Node{
        int v; Node next;
        Node(int x, Node t){
            v = x;
            next = t;
        }
    }
    private class AdjListPrvtImpl implements AdjList{
        private int vertex;
        private Node node;

        AdjListPrvtImpl(int v){
            this.vertex = v;
            node = null;
        }

        @Override
        public int beg() {
            // TODO Auto-generated method stub
            node = adj[vertex];

            return node == null ? -1 : node.v;
        }

        @Override
        public int nxt() {
            //
            if (node != null) node = node.next;
            return node == null ? -1 : node.v;
        }

        @Override
        public boolean end() {
            // TODO Auto-generated method stub
            return node == null;
        }
    }

    private Node[] adj;

    GraphAdjList(int V, boolean flag){
        vertCount = V;
        directedGrph = flag;
    }

    public int getVertCount() {
        return vertCount;
    }

    public int getEdgeCount() {
        return EdgeCount;
    }

    public boolean isDirectedGrph() {
        return directedGrph;
    }

    public AdjList getAdjList(int vertices){
        return new AdjListPrvtImpl(vertices);
    }

    @Override
    public void Graph(int vertCnt, boolean dir) {
        // TODO Auto-generated method stub
        vertCount = vertCnt;
        directedGrph = dir;
    }

    @Override
    public int V() {
        // TODO Auto-generated method stub
        return vertCount;
    }

    @Override
    public int E() {
        // TODO Auto-generated method stub
        return EdgeCount;
    }

    @Override
    public boolean directed() {
        // TODO Auto-generated method stub
        return directedGrph;
    }

    @Override
    public int insert(Edge e) {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public void remove(Edge e) {
        // TODO Auto-generated method stub

    }
    }
</code>```

Most of the stuff with edges has to deal with Adjacency Matrix operations. So I left it unimplemented.

Body:
Here is something I dug up.  If anyone has a better implementation I will mark his remark as the answer...

public interface AdjList {
    int beg();
    int nxt();
    boolean end();
}

public class Edge {
    int v, w;
    //E value;
    Edge(int v, int w){
        this.v = v;
        this.w=w;
    }
}

public class GraphAdjList implements IGraph{
    private int vertCount, EdgeCount;

    private boolean directedGrph;

    private class Node{
        int v; Node next;
        Node(int x, Node t){
            v = x;
            next = t;
        }
    }
    private class AdjListPrvtImpl implements AdjList{
        private int vertex;
        private Node node;

        AdjListPrvtImpl(int v){
            this.vertex = v;
            node = null;
        }

        @Override
        public int beg() {
            // TODO Auto-generated method stub
            node = adj[vertex];

            return node == null ? -1 : node.v;
        }

        @Override
        public int nxt() {
            //
            if (node != null) node = node.next;
            return node == null ? -1 : node.v;
        }

        @Override
        public boolean end() {
            // TODO Auto-generated method stub
            return node == null;
        }
    }

    private Node[] adj;

    GraphAdjList(int V, boolean flag){
        vertCount = V;
        directedGrph = flag;
    }

    public int getVertCount() {
        return vertCount;
    }

    public int getEdgeCount() {
        return EdgeCount;
    }

    public boolean isDirectedGrph() {
        return directedGrph;
    }

    public AdjList getAdjList(int vertices){
        return new AdjListPrvtImpl(vertices);
    }

    @Override
    public void Graph(int vertCnt, boolean dir) {
        // TODO Auto-generated method stub
        vertCount = vertCnt;
        directedGrph = dir;
    }

    @Override
    public int V() {
        // TODO Auto-generated method stub
        return vertCount;
    }

    @Override
    public int E() {
        // TODO Auto-generated method stub
        return EdgeCount;
    }

    @Override
    public boolean directed() {
        // TODO Auto-generated method stub
        return directedGrph;
    }

    @Override
    public int insert(Edge e) {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public void remove(Edge e) {
        // TODO Auto-generated method stub

    }
    }

Most of the stuff with edges has to deal with Adjacency Matrix operations. So I left it unimplemented.


问:
Why do .Net books talk about stack vs heap memory allocation?
It seems like every .net book talks about value types vs reference types and makes it a point to (often incorrectly) state where each type is stored - the heap or the stack.  Usually it's in the first few chapters and presented as some all-important fact.  I think it's even covered on certification exams. Why does stack vs heap even matter to (beginner) .Net developers?  You allocate stuff and it just works, right?</p>

答:
There can be some edge cases where it that can make a difference. The default stack space is 1meg while the heap is several gig. So if you're solution holds a large number of object you can run out of stack space while having plenty of heap space.

However, for the most part it is pretty academic.


问:
Designing Algorithm Flowchart Application
I need to develop an GUI application in C# where users can freely add conditional/statement blocks on the algorithm flowchart like the one shown below. By freely, I mean users can add a block on wherever the arrows are.

I'm having some problems brainstorming how to approach this problem, especially what to choose for my datastructure to store the blocks. I was thinking LinkedList since everything follows a linear fashion and every node always has a head and tail, but the If/Else block (b>a) has two branches (heads) to store, so this complicates things a little bit.

How would a smart one approach problems like this? My apologies if this question isn't suited for Programmers stackexchange, but this is more of a conceptual problem rather than implementation problem so I figured this place was appropriate for the question.

答:
I did something similar to this in Java.

I built my own linked list.  I had a List of Activities and a List of Connectors.

The Activity class had a integer that acted as the key to the class.  It was a sequential counter starting from 0.  The Activity class can be extended to draw the different Activity shapes that you need to represent.  Each shape has a bounding Rectangle, so you can attach the Connectors to the appropriate places.

The Connector class had two integers, which represented the from Activity and the to Activity.  This way, it didn't matter whether or not an Activity had more than one connector.


问:
What is 'work' in the Pomodoro Technique?
I have just started to use Pomodoro today and I am trying to work out what I should and should not do during my 25 minute work time.

For my 25 minute work stint I started to write some code and realised that I had done something similar in a related project so I opened that solution to copy and paste that existing code. Question is, is this allowed?

Also, if during my 25 minutes I realise that there is an important work-related email that I need to send can I do that or should I wait for the next 25 minutes or the break ?

I am writing this question during my, now extended, 5 minute break. Is this work or is it a break?

I really will appreciate some guidance as I want to use Pomodoro to focus better on my work.

Another thing that happened to me was that a Adobe AIR update alert came up on my desktop during the 25 minutes. Should I ignore such things until the break?

Sachin

答:
"Work" should be things that don't interrupt your train of thought on the task you chose for that pomodoro.  Writing code includes researching existing solutions, talking to coworkers, or whatever you need to do to keep writing the code.  Things like an email you should write down a reminder to get it out of your head, but wait until the next pomodoro to actually write it.

Things like an Adobe AIR update depends on how much it's going to interrupt you.  If it would take less time to just hit the update button, and you can continue on with your work, do it.  If the update would disrupt your work, write down a reminder and put it off.  The idea is to deal with interruptions in the most efficient manner possible without breaking your train of thought.


问:
Is there a sequence to read through the Android developer site for a user new to Android?
To summarize: I can buy a book, people say "Just read the developer site", I like to be spoon-fed the early learning piece for a technology, what path through the developer site will give me that spoonfeeding I need (that is, examples tied directly to the section being discussed, a clear path, etc.).

I keep seeing that I don't need to buy an Android development book, that I should just read the Android developer site, because it has everything I need to know. I see it more as drinking from a fire hose.

But I'm one of those people who likes to be walked through the basics. I like to build up my knowledge, rather than being dropped into reference documentation. I also like to make sure I have see all/most of the topics covered. I'd hate to develop the wrong thing, because I don't know about Fragments, Content Providers, or whatever.

So, since it's a great resource, better than any book (we don't need no stinking books), how do I traverse the site to get the information provided in the same way as a book would lay it out?

答:
The community college I attend actually has a course in learning how to program in Android. We're learning the basics (and some advanced) of Java first and then moving on to Android. The textbook does a pretty good job of explaining things and, to my knowledge, is one of the only Android Programming textbooks out there. Here is a link to it at Amazon: http://www.amazon.com/Android-How-Program-Series-ebook/dp/B007HDPSAU/ref=pd_rhf_ee_p_t_3

I have the ebook for my iPad. Maybe a textbook could help you! It has some Self-Assement questions (and their answers). Good luck :)


问:
How to implement a text editor in a browser?
This is purely an exercise in self improvement and education.I am trying to implement an extension for a vi-like text editor within a browser. Can anyone give any advice or pointers as to where and how I should start?</p>

答:
Short Answer: There are number of open-source text editors in the market. I would grab one and look at their code base. Improve it if you can, and share back with community.

For example, if you are using a CMS based framework system like Joomla, you may look at variety of  editor tools here.

You may also look and select from variety of jQuery based text-editors from - 10 jQuery and non-jQuery javascript Rich Text Editors


答:
Writing an editor to run inside a browser is not that different.

Use Javascript. Use a
 to render your buffer; when you update its contents or alter styles of elements inside it, the browser will repaint it for you. Quite probably, in a line-oriented vi-like editor it's convenient to have every line in a separate nested div, too.

Use onkeydown, onclick and other such event handlers to react on user actions.

The rest is up to you.

Title: How to implement a text editor in a browser?

Body: This is purely an exercise in self improvement and education.I am trying to implement an extension for a vi-like text editor within a browser. Can anyone give any advice or pointers as to where and how I should start?</p>

Body:
Writing an editor to run inside a browser is not that different.

Use Javascript. Use a <div> to render your buffer; when you update its contents or alter styles of elements inside it, the browser will repaint it for you. Quite probably, in a line-oriented vi-like editor it's convenient to have every line in a separate nested div, too.

Use onkeydown, onclick and other such event handlers to react on user actions.

The rest is up to you.


问:
What are the options for setting up a UNIX environment to learn C using Kernighan and Richie's The C Programming Language?
I'm a novice programmer and have been experimenting with Javascript, jQuery and PHP but felt I wasn't getting a real depth of understanding of what I was doing. So, after reading Joel Spolsky's response to a question on this site (which I can't find now!), I took it back to basics and read Charles Petzold's 'Code' and am about to move onto Kernighan and Richie's The C Programming Language. I want to learn this in a UNIX environment but only have access to a Windows system. I have Ubuntu 12.04 running on a virtualised machine via VMWare Player, and done some coding in the terminal.

Is using a Linux distro the only option for programming in a UNIX environment on Windows? And what are the next steps to start programming in C in UNIX and where do I get a compiler from?

答:
If you really don't want to move to Linux, or continue using Linux on a virtual machine, you could give Cygwin a try. It's:

a collection of tools which provide a Linux look and feel environment for Windows.

a DLL (cygwin1.dll) which acts as a Linux API layer providing substantial Linux API functionality.

More importantly, it makes The GNU Compiler Collection available on Windows. A similar tool, but a bit more tuned for developers is MinGW. It includes:

A port of the GNU Compiler Collection (GCC), including C, C++, ADA and Fortran compilers;

GNU Binutils for Windows (assembler, linker, archive manager)

A command-line installer (mingw-get) for MinGW and MSYS deployment on MS-Windows

A GUI wrapper (mingw-get-inst) for the command line installer

Everything you need, and then some.


答:
When I use the Pomodoro Technique, I always start by formulating a sentence that captures what I set out to accomplish during the next 25 minutes. For example "I need to figure out what's wrong with this loop" or, when studying, "I need to understand this theorem".

Every time something unexpected pops up, ask yourself: "Is this directly related to the goal I set for these 25 minutes?" Copying and pasting code seems directly related. Emailing would also be OK, if it was directly related to the goal. Any other mails will have to wait. Asking questions on SA is OK, if and only if it is directly related to the goal, and so on.

Using this technique has really helped increase my focus. I get more things done in less time because I'm concentrating solely on the problem at hand, and not one of the other thousand other things calling for attention.

Title: What is 'work' in the Pomodoro Technique?

Body:
I have just started to use Pomodoro today and I am trying to work out what I should and should not do during my 25 minute work time.

For my 25 minute work stint I started to write some code and realised that I had done something similar in a related project so I opened that solution to copy and paste that existing code. Question is, is this allowed?

Also, if during my 25 minutes I realise that there is an important work-related email that I need to send can I do that or should I wait for the next 25 minutes or the break ?

I am writing this question during my, now extended, 5 minute break. Is this work or is it a break?

I really will appreciate some guidance as I want to use Pomodoro to focus better on my work.

Another thing that happened to me was that a Adobe AIR update alert came up on my desktop during the 25 minutes. Should I ignore such things until the break?

Sachin