问:
c++ Model View Presenter: Where to construct presenter?
I'm using the Model View Presenter (MVP) pattern as described in The Humble Dialog Box paper (pdf) with an MFC project.  I'm sure the issue is the same with most GUI toolkits.

The thing that's bothering me is the concrete view (i.e., the dialog class) is creating not only the presenter but also the services that the presenter needs.  Is that normal?  Why does the view need to know what services the presenter needs?  What I'm thinking is that I should dependency inject the presenter into the dialog class.

The main control for the application is a class derived from CWinApp.  So should I construct services and presenter in this class and then inject them into the dialog class?

Although how would I dependency inject the presenter into the dialog class when the presenter needs a reference to the view class in it's constructor?

MyPresenter(IView *view, MyService *service);

Also how about if the main window spawns off a popup window, where should the details for that windows presenter and services get constructed?

Since this is C++ I don't think I'd be interested in any kind of DI framework.

UPDATE

One idea I had was to construct the presenter with a null view, constructor inject the presenter into the dialog class, and then in the constructor of the dialog class call a SetView(IView *view) method on the presenter with this where this would be the dialog class (which derives from IView).  So:

```<code>MyApp::Start()
{
  SomeService *service = new SomeService();
  MyPresenter *presenter = new MyPresenter(null, service);
  MyDialog *dialog = new MyDialog(presenter);
  ...
}

MyDialog::MyDialog(MyPresenter *presenter):
 presenter_(presenter)
{
  presenter_->SetView(this);
}
</code>```

Seems a little kludgy but keeps service construction out of the Dialog class.  The null view seems a little dangerous.  An alternative would be to actually construct a NullView class that had empty method bodies and then pass that into the presenter constructor.

答:
I think your original idea (constructing presenter and service inside of the view) does no harm.  We have to ask ourselves benefit of the injection and I don't see any.

By separating actual view into abstract view and presenter, you already achieved separation of concerns. And you can get benefit from the achievement, for example, by testing presenter with stuffed or mocked view. So why would you want to inject the presenter into concrete view? I don't see any necessity.


问:
Why is it good not to rely on changing state?
This question arises out of the question https://softwareengineering.stackexchange.com/questions/25569/is-haskell-worth-learning

Generally a few often repeated statements are made, about how Haskell improves your coding skills in other languages, and furthermore, this is because Haskell is stateless, and that's a good thing.

Why?

I've seen someone compare this to only typing with the left hand, or perhaps closing your eyes for a day and just relying on touch. Surely there is more to it than that?

Does it relate to hardware memory access, or something else which is a big performance gain?

答:
As the author of Siege, a DBMS written in Haskell, some may call my view on mutable state conflicted. I hope to show otherwise.

The purpose of mutable state is to describe the current state that a system is in. Say you have a blog and it is backend by a database, the database describes the posts that you have on your blog at the point in time at which you query it. How many posts exist right now?

Contrast this with immutable state that is used to convey facts. How many posts were there on 12th August?

Facts are easy to reason about, mutable state is not. However, mutable state is not some evil impure effect that should be banished from the reaches of ours minds; we often need it to coexist in the mutable world we live in, we just need to use it more sparingly.

ContentLicense: CC BY-SA 2.5

ContentLicense: CC BY-SA 3.0


问:
Can we guarantee a program will never go wrong?
We have a system here. Recently there is a wrong calculation in one of the number in the report generated by the system. Through out our experience, we've never encounter any problem/error in this system for some years.

Because the writer of this system had already gone, we can hardly trace the programs. But we've verify the input data, the setting and they are right.

Now my question is, will a computer program suddenly go wrong without any logical reason? If I slam on the server machine, will one of the number which the computer is calculating, become another number and make the calculation wrong?

I agree my idea there is quite mad, but I just want to know, how can we know the problem is not caused by the program and the input, but some other factors?

P.S. This mad system has no log.

答:
Unless you can control every single bit in the machine, and every bit of electrical impulse flowing through the circuitry, then you cannot guarantee with absolute certainty that something will not go wrong with your program. Memory modules fail, CPUs can overheat and introduce errors, hard drives can scramble data, and power supplies can introduce noise into the system. The more expensive the hardware, and the more redundant the hardware, the less likely these things will occur, but at some point hardware can fail.

Then you have the operating system, with bugs that can be tickled by the most arcane means imaginable. Compilers may also have obscure bugs just waiting to deftly turn your pristine code into hard-to-trace bugs. It's a jungle out there, and your poor software is vulnerable to all of this. LOOK OUT!

And in my experience, more often than not, whenever there's a bug in a calculation, we never have to dig nearly that far to find the culprit. Generally speaking almost all bugs I've seen in the corporate world are easily found with the right debugging tools, and some elbow-grease.

In other words, while the hardware and OS might not be perfect, you'll likely never have to worry about that level of detail. Just find someone who knows the language, and is handy with a debugger, and dig in.

"simpler explanations are, other things being equal, generally better than more complex ones." -- Summarization of Occam's Razor.


问:
Are separate parsing and lexing passes good practice with parser combinators?
When I began to use parser combinators my first reaction was a sense of liberation from what felt like an artificial distinction between parsing and lexing.  All of a sudden everything was just parsing!

However, I recently came across this posting on codereview.stackexchange illustrating someone reinstating this distinction.  At first I thought this was very silly of them, but then the fact that functions exist in Parsec to support this behavior leads me to question myself.

What are the advantages/disadvantages to parsing over an already lexed stream in parser combinators?

答:
One of the main advantage of separate parse / lex is the intermediate representation - the token stream. This can be processed in various ways that would otherwise not be possible with a combined lex/parse.

That said, I have found that good 'ol recursive decent can be less complicated and easier to work with vs learning some parser generator, and having to figure out how to express the weakness of the grammer within the rules of the parser generator.


问:
Why should we use low level languages if a high level one like python can do almost everything?
I know python is not suitable for things like microcontrolers, make drivers etc, but besides that, you can do everything using python, companys get stuck with speed optimizations for real hard time system but does forget other factors which one you can just upgrade your hardware for speed proposes in order to get your python program fit in it, if you think how much cust can the company have to maintain  a system written in C, the comparison is like that:
for example: 10 programmers to mantain a system written in c
and just one programmer to mantain a system written in python,
with python you can buy some better hardware to fit your python program, I think that low level languages tend to get more cost, since programmers aren't so cheaply than a hardware upgrade,
then, this is my point, why should a system be written in c instead of python?

答:
Well I understood your question as "Why continue to write things in C/C++ when better alternatives are present."  Not let's rewrite everything just because we have a better hammer.  And I agree with you in theory.  Why write new things in C or ASM anymore because it turns out there are vastly more problems that work better for "high-level" languages than not.

I think about a story that James Gosling recalled about the Java team.  They were looking at huge sections of code in the VM that was originally written in C because they thought it was faster.  As time went on and they had to improve it, maintain it, and add new features.  The team began to wonder why not move it to Java.  They did and it turned out to be just as performant, simpler, and easier to modify.  I do think new development should not be done in C/C++, except for those exceptions noted, but what makes our industry continue to grow is the platform change.  We haven't really answered any new questions about computer science since the 70s, but we continue to grow in amazing directions.  That's largely because every 10 years or so we create new platforms where we have to re-implement everything over there opening up opportunities to transition from previous languages to new ones.  That's the secret to our industries success.

Here's a simple wrap up from 1980-2010:  Unix C->Windows C++->Web Java/Javascript/Python/Ruby->mobile Objective C/Java).


问:
Are there any podcasts (not lectures) about compiler development?
There are several podcasts with lectures from universities. I am looking for "other" podcasts.

So are there any non-lecture podcasts about compiler development?

答:
Below are podcasts on compiler development from Software Engineering Radio:

Episode 61 Internals of GCC

Episode 182 Domain Specific
Languages

Episode 160 Aspect J and Spring AOP

Episode 118 Eelco Visser on Parsers

Episode 57 Compile time Meta Programming

Episode 44 Interview with Brian Goetz and David Holmes

Episode 36 Interview with Guy Steele

Oresoft Live Web Class:

Compiler Design (42 videos)

Blip.tv

Introduction to Compilers

Google Tech Talks:

LLVM

Learning to Analyze Sequences

Code Generation with Ruby

Compiling Dynamic Languages

GCC: Current Topics and Future Directions

Compiling and Optimizing Scripting Languages

Building Industrial Strength Performance Tools

DMS: Software Tool Infrastructure

Tools for Continuous Integration at Google Scale

Cross Compiling Android Applications to iPhone

YouTube:

How the Compiler Works

Lexical Analysis

Syntax Analysis

Code Generation and Optimization

Code Generation of the JVM

Lexical Scanning in Go

Channel 9:

Eric Lippert - On Compiler Evolution, Designing C# and Blogging

Confreaks:

Towards a Ruby Compiler

How to Implement your own Programming Language

TWIT Network's Floss Weekly discussed related topics:

Guido van Rossum (language design)

PHP Creator Rasmus Lerdorf (origins of PHP)

Superfeedr

Computer Science Podcast has:

May 2011 Compilers Everywhere


问:
What are the relative advantages of dictionaries versus databases?
I have an environment that supports both dictionaries (json style) and databases (not relational or anything, just formatted data by row and column). My application doesn't really need database functionality, butI'm somewhat more comfortable with the database system than I am with dictionaries. Is there a major performance advantage to dictionaries? What situations are there where a dictionary is better than a database?</p>

答:
If you want to know whether there is a performance advantage, the best thing to do is measure it yourself. The performance depends a lot on the type of data, the language, the amount of data, etc.

It's impossible to give a blanket statement as to when dictionaries are better than databases. Again, it depends on the data, the language, etc. Roughly speaking, dictionaries are better for simple and small datasets, and databases are good for complex and large data sets.


问:
Where to find resources to write a program like sandboxie?
Sandboxie is a program that will let you read from the hard drive, but when you try to write back it will redirect the file to a separate container. I would like to learn how to do something similar. I do not know what terms or libraries to look for. Is there a file redirection API in windows? Is there a open source library that can help me out with the down and dirty pieces?

I know there is likely no API in windows to do this out of the box and I will likely need to write my own driver. I don't mind writing a driver, this project is to be a learning experience for me and I kind of want to learn how to do it.

Any help would be greatly appreciated.

Clarification:

I am trying to replicate the behavior of sandboxie, IE: launching a unmodified exe of another program and redirecting the way it handles file IO.

What I want to do is basically have a launcher that will turn my SSD disk in to a cache for my spinning drive. I launch my app and it in turn launches another app. Any resources the other app requests will be passed through to the spinning disk, but also copied to the SSD. Any further reads and all writes will be done to the SSD copy of the file. Once the other program closes, my app will flush the writes from the SSD back to the spinning disk.

I could technically do this through sandboxie and some scripting tricks but I want to learn the internals of file IO and how to do the redirection.

Clarification 2:

I no-longer have a issue using a prebuilt library, as long as it is free (as in beer). It does not need to be open source or free (as in speech)
.

答:
Have you tried contacting Ronen Tzur via his forums for more information about his software?

Ronen Tzur provides some details about Sandboxie's design in Security Now Episode 172 Sandboxie.

Steve Gibson discuses the limitations of sandboxing in Security Now Episode 174 Virtual Security.

You can also read the show notes for episodes 172 & 174 here.


问:
Pseudocode for an echo using recursion
Using pseudocode, what would the code for an echo using recursion be?

UPDATE: Appears I should have been more clear. By echo I mean the pattern sound exhibits when it echos, not echo as in repeatly add one to self where self equals zero. Any thought on what the code would look like for a "real" echo? For example, I'd thought about "echo(reduce-volume();exit-if-silent;echo())" but was sure if the logic made sense.

UPDATE-2: Working through my own logic above an noticed it lacks a way to account for "positive feedback", which I'm guessing is required.

http://en.wikipedia.org/wiki/Positive_feedback

答:
```<code>echo sound clip S at volume V:
    if V is zero, done. (Exit recursion.)
    start playing S.
    V = V * F.
    Wait for time T.
    echo sound clip S at volume V.
</code>```

F is the attenuation factor, and I suppose a good value for it would be 0.5

T is the delay between repetitions of the echo, it simulates the distance of the echoing wall.

Note: of course, this is just tail recursion, so it can be trivially converted into a loop. However, it is possible to extend it to simulate multiple echoing walls at different distances, in which case the recursion might be the best way to do it.

Positive feedback cannot be accounted for without working with the individual samples that the waveform is composed of, which calls for an altogether different, and far more complicated solution.

Title: Pseudocode for an echo using recursion

Body:
echo sound clip S at volume V:
    if V is zero, done. (Exit recursion.)
    start playing S.
    V = V * F.
    Wait for time T.
    echo sound clip S at volume V.

F is the attenuation factor, and I suppose a good value for it would be 0.5

T is the delay between repetitions of the echo, it simulates the distance of the echoing wall.

Note: of course, this is just tail recursion, so it can be trivially converted into a loop. However, it is possible to extend it to simulate multiple echoing walls at different distances, in which case the recursion might be the best way to do it.

Positive feedback cannot be accounted for without working with the individual samples that the waveform is composed of, which calls for an altogether different, and far more complicated solution.


问:
How should I control the versions of my project on GitHub
I am trying to spend as much time as I can on GitHub nowadays (even I am the only person in team at work) to really feel how it is going to be like for a real world corporate application.

One question I am having is to controlling the version. Let's say we started a project. Then, team members created some branches and develop there. When we are ready for the production, we merged all of branches with master branch. At the end, we go live with version 1.0.

Now that version 1.0 is live and we have some issues filed for that version of that software. We would like to start developing for version 1.1 in order to fix those issues that we had introduced by rushing the project.

Now, the question is this:

How should we control the versioning here?

Should we create a new branch for v1.0 and keep the version 1.0 of the software there and develop on some branches (or not), merged them with master, go live with version 1.1?

Is there convention out there for those kind of situations?

答:
What I've witnessed most of the time is:

Master is for you product. Eventually all your future version x.0 will be on master.

You create a tag/branch for each version in production so you can still support them for any customer that requires it.

Merging fixes from one or the other is to deal on a per case basis.


答:
Everyone suggesting that separating lexing and parsing is a "good practice" -- I have to disagree - in many cases performing lexing and parsing in a single pass gives much more power, and performance implications are not as bad as they're presented in the other answers (see Packrat).

This approach shines when one has to mix a number of different languages in a single input stream. This is not only needed by the weird metaprogramming-oriented languages like Katahdin and alike, but for much more mainstream applications as well, like literate programming (mixing latex and, say, C++), using HTML in comments, stuffing Javascript into HTML, and so on.

Title: Are separate parsing and lexing passes good practice with parser combinators?

Body:
When I began to use parser combinators my first reaction was a sense of liberation from what felt like an artificial distinction between parsing and lexing.  All of a sudden everything was just parsing!

However, I recently came across this posting on codereview.stackexchange illustrating someone reinstating this distinction.  At first I thought this was very silly of them, but then the fact that functions exist in Parsec to support this behavior leads me to question myself.

What are the advantages/disadvantages to parsing over an already lexed stream in parser combinators?


答:
I have found (and started to adopt) the following branch model:

(image from the article)

There are lots of great practices and strict rules described in that article, I highly recommend it.

Points of interest:

The master branch is where you tag your versions. No development happens here. In case of a bug that was deployed in production, you fix the bug on a hotfix branch, merge back and tag a new version.

Development happens on the devel and feature branches. Personally, I do bugfixing on the devel branch and features on feature branches.

When the software starts to reach a release, I branch off to release branch. The release branch is where I do the final touches. Bump version numbers, change metadata etc. And minor bugfixes. When it is finished, I merge it to master, tag and call it a version.

The two main branches: master is the "holy branch"; its HEAD is always the latest production code, and develop is the nightly branch; its HEAD always reflects the latest (but possible unstable) additions to the code.

In your specific case, the steps would depend on how rushed was that version. If it's features that were left out, I would go back to the develop release and do the whole thing again. If it's bugs in the deployed version, I would branch off to a hotfix branch, fix the bugs, merge back and tag v1.1. If it's both, I would fix the bugs first, then add the features second as described.

Title: How should I control the versions of my project on GitHub

Body:
I am trying to spend as much time as I can on GitHub nowadays (even I am the only person in team at work) to really feel how it is going to be like for a real world corporate application.

One question I am having is to controlling the version. Let's say we started a project. Then, team members created some branches and develop there. When we are ready for the production, we merged all of branches with master branch. At the end, we go live with version 1.0.

Now that version 1.0 is live and we have some issues filed for that version of that software. We would like to start developing for version 1.1 in order to fix those issues that we had introduced by rushing the project.

Now, the question is this:

How should we control the versioning here?

Should we create a new branch for v1.0 and keep the version 1.0 of the software there and develop on some branches (or not), merged them with master, go live with version 1.1?

Is there convention out there for those kind of situations?


问:
What other reasons are there to write interfaces rather than abstract classes?

Possible Duplicate:

  When to use abstract classes instead of interfaces and extension methods in C#?

When I read and looked at codes using Abstract classes, I was able to justify it because it allows you to add common methods for any subclasses extending the abstract class. So for example, if objects behavior is similar, I would use Abstract classes to implement bodyless abstract methods that is required for each object, and simply use non abstract methods already implemented in the abstract class. I can think of a scenario dealing with multiple media file types (avi,mpg,mp4) and you would have common methods for all files, as well as media specific abstract methods that needs to be implemented.

However, I am a bit confused as to why you would knowingly create an interface which cannot contain any non-abstract methods. Reading this page, it states that it hides information (you mean the abstract methods?).

Hiding details and providing common interfaces is called
  encapsulation, which is an analogy from making an object look like
  it's covered by a capsule (the interface in this case). This allows
  two objects differing in internal representation but having the common
  interface interchangeably usable (called interchangeability).
  Interfaces also allow to facilitate the use of data structure and
  guard the state of the object from invalid inputs and modification of
  the structure.

So does this mean that any objects which share the common behaviors implemented uniquely can be treated like they are the same category? So for the media file example, does this mean any specific media file type implementing the interface MediaFile are to be passed as arguments for a method dealing with such type of objects?

```<code>public class ServiceClass {
    public ServiceClass(){
    //no-args constructor
    }

    public boolean runService(ICollaborator collaborator){
    if("success".equals(collaborator.executeJob())){
        return true;
    }
    else
    {
        return false;
    }
}
}
</code>```

But can't you do above with an abstract class? Also, isn't the ability of having a non-abstract method better than having none at all for the future when you suddenly need to have an existing method that will apply to all classes extending the abstract class?

Or is the difference of using Interface, the ability to protect the implementation of data completely? Once again, I don't see what cases you would use it. Other than that I implement ActionListener quiet often to have the actionPerformed method.

答:
Interfaces are used in situations where the object doesn't matter only that it has a particular interface defined. For example:

```<code>function (Interface Object)
{
    // Use a method defined in Interface.
    Object.Method();
}
</code>```

Then we can pass any object to this function knowing that all objects (whatever they might be) have the interface defined so we are safe to use those methods.

More information here: https://stackoverflow.com/questions/383947/what-does-it-mean-to-program-to-an-interface

Body:
Interfaces are used in situations where the object doesn't matter only that it has a particular interface defined. For example:

function (Interface Object)
{
    // Use a method defined in Interface.
    Object.Method();
}

Then we can pass any object to this function knowing that all objects (whatever they might be) have the interface defined so we are safe to use those methods.

More information here: https://stackoverflow.com/questions/383947/what-does-it-mean-to-program-to-an-interface


问:
Is the GoF book still the one to read?

Possible Duplicate:

  Is there a canonical book on design patterns?

I'd like to read a design patterns book. GoF for sure is the one to read. But after 15 years is it still valid, I mean isn't there an updated one?

Something like "Charles Darwin On the origin of species" is a very important book, and some main concepts are still valid, anyway today (2010) one would read another book to study the subject.

In this question the main suggestions are the Head First and GoF books. But Head first is not a replacement for GoF.

So any suggestion or should I stick with GoF?

答: Definitely one to keep a copy of around. I've had the GoF book since I first started in software and find it's once one of those books that I get more out of every time I re-read it (and no, I don't read the whole thing cover-to-cover - just the odd pattern here and there). It is, however, one of those books that I felt as a "beginner", I never got as much out of it as i did later in my career. I found that having more experience makes the book a much more interesting and, of course, more relevant.</p>

Title: Is the GoF book still the one to read?


答:
To cut a long story short, (since this question for some reason is not getting closed,) interfaces are essential for single-inheritance languages like Java and C# because that's the only way in which you can aggregate different behaviors into a single class.

In other words, when you write class A which expects to be passed a reference to some B thing to work with, it helps if you declare B to be an interface and not an abstract class, because if it is a class then you will be forcing the author of class C who wants to write C so that it works with your A to derive their class from class B, while they may have other plans for it, which may demand that C derives from some other class D, which you may have never heard of. By writing A so that it accepts an interface of type B instead of an abstract class B, the author of C is free to derive his class from D and also implement interface B for the sake of working with your class A.

Title: What other reasons are there to write interfaces rather than abstract classes?

Body:
Possible Duplicate:

  When to use abstract classes instead of interfaces and extension methods in C#?

When I read and looked at codes using Abstract classes, I was able to justify it because it allows you to add common methods for any subclasses extending the abstract class. So for example, if objects behavior is similar, I would use Abstract classes to implement bodyless abstract methods that is required for each object, and simply use non abstract methods already implemented in the abstract class. I can think of a scenario dealing with multiple media file types (avi,mpg,mp4) and you would have common methods for all files, as well as media specific abstract methods that needs to be implemented.

However, I am a bit confused as to why you would knowingly create an interface which cannot contain any non-abstract methods. Reading this page, it states that it hides information (you mean the abstract methods?).

Hiding details and providing common interfaces is called
  encapsulation, which is an analogy from making an object look like
  it's covered by a capsule (the interface in this case). This allows
  two objects differing in internal representation but having the common
  interface interchangeably usable (called interchangeability).
  Interfaces also allow to facilitate the use of data structure and
  guard the state of the object from invalid inputs and modification of
  the structure.

So does this mean that any objects which share the common behaviors implemented uniquely can be treated like they are the same category? So for the media file example, does this mean any specific media file type implementing the interface MediaFile are to be passed as arguments for a method dealing with such type of objects?

```<code>public class ServiceClass {
    public ServiceClass(){
    //no-args constructor
    }

    public boolean runService(ICollaborator collaborator){
    if("success".equals(collaborator.executeJob())){
        return true;
    }
    else
    {
        return false;
    }
}
}
</code>```

But can't you do above with an abstract class? Also, isn't the ability of having a non-abstract method better than having none at all for the future when you suddenly need to have an existing method that will apply to all classes extending the abstract class?

Or is the difference of using Interface, the ability to protect the implementation of data completely? Once again, I don't see what cases you would use it. Other than that I implement ActionListener quiet often to have the actionPerformed method.


问:
what kind of relation will exist between a member and a P2P network classes in a class diagram?
I have a member class which stores the IP, and ports used on that member.
Another class P2P stores a list of all the members currently in the network and provides join,leave functionality. What kind of relationship will exist between them in  a class diagram?</p>

答:
The P2P list 'has a' member, use Aggregation relation

a variant of the "has a" association relationship; aggregation is more specific than association. It is an association that represents a part-whole or part-of relationship. As a type of association, an aggregation can be named and have the same adornments that an association can. However, an aggregation may not involve more than two classes.

Aggregation can occur when a class is a collection or container of other classes, but where the contained classes do not have a strong life cycle dependency on the container — essentially, if the container is destroyed, its contents are not.

In UML, it is graphically represented as a hollow diamond shape on the containing class end of the tree with a single line that connects the contained class to the containing class.The aggregate is semantically an extended object that is treated as a unit in many operations,although physically it is made of several lesser objects...


问:
Should I learn java for mobile application development or will C# just do?
I'm looking forward to delving into the .NET framework but most mobile applications seem to be developed in Java. I'll most probably be targeting the less pricier phones like Nokia and motorolla not android or iphone OS. Can I do these stuffs in C#?</p>

答: Maybe file this under "lateral thinking", but if you have decent skills in "pure" web technologies - HTML, JavaScript, CSS - and depending on what you're trying to achieve, check out something like PhoneGap (http://www.phonegap.com/about). In addition to support of iOS devices (iPhone, iPad) and Android, they also have some support for Symbian. You will, however, generally need the "native" tools in order to build your native binary apps. For example, if you want to do iPhone dev, you'll need the iPhone sdk, XCode and be running OSX.</p>

OwnerDisplayName: Alexander Suraphel


问:
Should QA be part of the development department?
I work for a small company that has had a product development department for quite a while. What we haven't had, however, is a QA/testing group.

We are looking to add a testing group, but are struggling to determine where best to put them in the organizational structure of the company. Specifically, we are going to hire a "lead tester" position. Should they be put in as part of the product development department, or should they be a new department? Should they be somewhere else?

Our company is roughly structured as follows:

CEO

CTO

Director Product Development

Director Customer Care

Developers

VP Operations

Network engineers

Sales/sales engineers

President

Controller

答:
It really depends on how serious your firm is about QA. For example will you be doing test driven development?

You mention a "testing group", this would suggest multiple people. If it is in fact a group of several people it should probably be a separate department. What puzzles me however is do you currently have at least one person devoted to QA and testing? If not, do you plan on standing up a whole new group quickly? If so this will be a substantial organizational transformation and may cause extensive friction with your current developers who need to change the way they work as well.

If what you are planning is hiring a single QA person now and perhaps slowly growing the QA function, then it would probably be better to have that person report directly to the director of product development. The toughest part of his job, and most important, will be to transform your organizational culture to integrate QA into all steps of the process rather than something that is done after the fact.


答: Depends on the development methodology you're using : if you're doing agile / lean then Agile Testing could be the way to go and as such would need to be close to developers.</p>

Title: Should QA be part of the development department?

Body:
I work for a small company that has had a product development department for quite a while. What we haven't had, however, is a QA/testing group.

We are looking to add a testing group, but are struggling to determine where best to put them in the organizational structure of the company. Specifically, we are going to hire a "lead tester" position. Should they be put in as part of the product development department, or should they be a new department? Should they be somewhere else?

Our company is roughly structured as follows:

CEO

CTO

Director Product Development

Director Customer Care

Developers

VP Operations

Network engineers

Sales/sales engineers

President

Controller


答:
From what you are saying, you have a pretty small company. It makes sense to me to take advantage of that size and ability to communicate while you can, before you become bigger. This implies keeping them with development.

In a larger company when you have decent sized Dev and QA teams, it might make sense to split them up then, and have them maintain their own, separate, team goals etc.

Now, I also would be sure to have the first few QA positions be SDET positions... ie. testers with coding chops. Get your automation up, running and stable from the start.


问:
Do you get the benefits of a B-Tree in a managed language?
My understanding is that one of the key features of a B-Tree (and a B+Tree) is that it is designed such that the size of its nodes are some multiple of the block size of whatever media the data is stored on.

Considering that, in a memory managed language like java/c#, we don't really have access to how, when and what order, data is accessed from the drive... can we still predictably benefit from the major advantage of this data structure?

答:
The use of a managed language like Java, C# etc. has absolutely nothing to do with the way data is accessed from the drive, and in any case it certainly does not deprive developers from an iota of control over precisely how, when, and in what order data will be accessed from the drive.

The problem is elsewhere: managed languages suffer from the overhead of managed-to-native and native-to-managed transitions, where data often need to be copied from native buffers into managed buffers, and from the fact that they do not offer quick and easy support for inherently unsafe operations like picking four bytes from within an array of bytes and interpreting them as an integer. So, when you want to do a thing like that you have to invoke a function that will do the conversion for you, where in C++ you would just use a single machine instruction which dereferences a pointer.

Therefore, an implementation of a B-Tree in a managed language will suffer, but it will not be due to lack of control over precisely how, when, and in what order data is accessed from the drive.


答:
Yes and no :)

Both developers and QA people should have the same goal (and their performance measured against that): deliver a quality product in time and on budget. You get to define "quality product", but it has to be the same for both groups. Why? Because if it isn't the same, you will get two groups with different agendas and that can quickly deteriorate into a situation that is to the detriment of the product/company.

QA should work (very) closely together with the developers and vice versa, but both should be totally independent of the other in their decision making. They are, after all, responsible for totally different aspects of product development

The way we have set it up is that "Product Development" is a "virtual" department realized by two concrete departments: QA and Development. Both report to the same member of the management team: the CTO. This ensures that there is a single person responsible for the product (our CTO) and that both QA and Development are independent of each other.


问:
Employer appeal; OOP use in mainstream; solutions that blossom with OOP
I'm currently in the process of what I hope to be a career change into the programming field.  Despite my wide range of knowledge in the field and additional exposure to concepts in college (which in the end left a lot to be desired), I feel I might be missing out on what really matters when appealing to employers.

I found this post https://stackoverflow.com/a/1991453 to be specific to my predicament.  Importantly:

I've seen a lot of terrible C++ code and it's not just from people who don't understand the concepts. I've seen a lot of coders who know exactly what an object is and can explain polymorphism and all those technical OOP terms perfectly. But if they don't know when to use it, they'll never be able to take full advantage of it. I know because I was like this myself. I had read a book on OOP in high school which explained all the concepts, but I went years before I actually used them because I didn't see when they'd actually benefit my code.

I am comfortable with OOP concepts but a little rusty with supporting languages like Java, C# (my favorite for OO), and even C++.  The reason I can't claim to be at least proficient in this area is because I'm not really sold on OO design; everytime I set out to solve a problem that can be done in OOP, I find myself forcing its use and end up making a procedural solution in C which I believe to be a much more elegant program.

I guess this involves three questions: Can I still (honestly) sell myself as being valuable to an employer given my skill-set strengths and weaknesses as explained above? Is there any projects or problems I can tackle solo (for practice) that is just smarter to do with OOP?  And given an object strong project, what language should I concentrate on?

答:
Like any other concept, OOP can be misused. I've seen many remark it's intended to map the real world concepts, and IMHO this path leads to eerie mind states from which subjects can not be expected to escape, producing nothing but crap.

Chances are your taste is right, and the non-object-oriented solution is better. I think all you lack is confidence.


答:
There's no such thing as an elegant program in C, unless you count exceedingly trivial examples. The advantages of OO become inherently apparent as soon as you try to do even something basic, like strings. If you can't see why std::string is so much better than C strings in every possible way, then you need to take a much closer look. I'll give you a head start by demonstrating some of the massive benefits:

The Standard string class handles all it's own memory- specifically, you are guaranteed to never, ever leak a std::string. This is way ahead of a C string.

The Standard string class offers O(1) size. C strings only offer O(n) size.

The Standard string class does not require NULL termination. This solves many off-by-one errors that exist in C string code.

The Standard string class cannot have it's memory freed by another user. It cannot have the memory be reallocated by another user. The ownership is explicit and enforced by the compiler. If you pass a char* to a function, they could attempt to free it when you already do that, or such things.

The Standard string class is smarter than you. Specifically, it can do things like small-string optimization without having to change your user code. If you wanted to implement SSO, you would have to refactor every single bit of code that uses strings. When std::string implements SSO, you don't even notice.

The Standard string class is generic. The function for sorting a vector of integers is just the same as the one for sorting a vector of strings, and it's faster than C's qsort too.

The Standard string class grows itself when it needs to. No more MAGIC_BUFFER_SIZE codes which overflow and are vulnerable, and you can guarantee that your library implementer spent an awful long time, much longer than you could ever justify spending, profiling and determining the optimum way in which to grow.

When you compile in Debug mode, the Standard string class will error-check your iterators and indexes, and when you request it, indexes in normal code too. Will a char[] do this for you? I doubt it.

So std::string is faster, safer, and more maintainable than C-strings. Other classes offer very similar reasons to be vastly superior in every possible fashion. What more do you want from object-orientation other than superior speed, correctness, and ease of maintenance?

Therefore, pretty much by definition, any C++ program that is equivalent to your C program but uses OO to handle strings is inherently and vastly superior to your C program.

The problem that you exhibt is most easily picked up on here:

I believe to be a much more elegant program.

You believe? Awesome. Why don't you actually go back and check? Because I think you'll find that actually, said programs are buggy and slow, and would be greatly improved by a judicious application of solid object orientation. Your subjective feelings arise for reasons that have nothing to do with the actual quality of the program.

You need to recognize that the objective qualities of speed, maintenance, and correctness of a program has absolutely nothing to do with your subjective opinion of whether or not it's elegant.

And you know what? Not every problem is best approached by OO. There's a reason that languages like C# have lambdas and generics, and it's because inheritance isn't a Swiss army knife. It's just one tool, and there are others which serve certain purposes better. It is, however, a remarkably effective tool for many situations, best used for structuring programs and modules.

Title: Employer appeal; OOP use in mainstream; solutions that blossom with OOP

Body:
I'm currently in the process of what I hope to be a career change into the programming field.  Despite my wide range of knowledge in the field and additional exposure to concepts in college (which in the end left a lot to be desired), I feel I might be missing out on what really matters when appealing to employers.

I found this post https://stackoverflow.com/a/1991453 to be specific to my predicament.  Importantly:

I've seen a lot of terrible C++ code and it's not just from people who don't understand the concepts. I've seen a lot of coders who know exactly what an object is and can explain polymorphism and all those technical OOP terms perfectly. But if they don't know when to use it, they'll never be able to take full advantage of it. I know because I was like this myself. I had read a book on OOP in high school which explained all the concepts, but I went years before I actually used them because I didn't see when they'd actually benefit my code.

I am comfortable with OOP concepts but a little rusty with supporting languages like Java, C# (my favorite for OO), and even C++.  The reason I can't claim to be at least proficient in this area is because I'm not really sold on OO design; everytime I set out to solve a problem that can be done in OOP, I find myself forcing its use and end up making a procedural solution in C which I believe to be a much more elegant program.

I guess this involves three questions: Can I still (honestly) sell myself as being valuable to an employer given my skill-set strengths and weaknesses as explained above? Is there any projects or problems I can tackle solo (for practice) that is just smarter to do with OOP?  And given an object strong project, what language should I concentrate on?


答:
OOP is inherently silly. Why would you ever write "object-oriented" code? Do people also build concrete-oriented houses? Wheel-oriented cars?

OOP takes a useful tool, and elevates it to a religion. An object can be very useful as a tool in helping you define your program. In the same way that a wheel is quite a useful component when building a car. It's just not something everything does, or should, revolve around as the term "OOP" implies.

Objects are useful because they enable us to define abstract datatypes. We can define a class which behaves like the concept we wish to model, and that simplifies all the code that manipulates these concepts. A string class is useful because it behaves like you'd expect a text string to behave. It defines a number of operations which you expect to be present when dealing with strings, and it prevents other, nonsensical operations which would be possible if you were working on the raw bytes it uses internally. It allows me to think about strings, instead of thinking about arrays and integers, which are used internally to define the string.

The same should be true for the objects you define yourself. They should provide abstractions and guarantees and invariants that allow you to forget about all the implementation details. The point in a class is that it should guarantee that it can never be "broken" or brought into an inconsistent state. That you can rely on it to behave like the concept it represents.

If you have some such objects, then you can use them as building blocks for your application.

But that doesn't mean your code needs to be "object-oriented". It doesn't mean that the objects should be your program, or that everything must be associated with an object.

OOP is nothing special. It's one programming paradigm out of many. There's object-oriented programming, there's generic programming, there's functional programming. There are "niche" ones such as logic programming, and "old-fashioned" ones like procedural programming. The point is that, generally speaking, OOP is not "best". It has had a powerful marketing machine behind it, but that doesn't make it superior.

The best you can do is try to learn as much as possible for as many different paradigms as possible. Then use what makes sense in the language you're currently working in. Some languages make OOP easier, and everything else harder, which generally means that OOP will be a more attractive choice. Others favor FP, and some allow just about any paradigm.

As for employers, the good ones will hire people who are good programmers.
The bad ones will chase buzzwords. (You know OOP? XML? SOAP? TDD? Great, you're hired!)

So don't worry too much about making yourself attractive to employers. Focus on making yourself a better programmer. This involves keeping an open mind and challenging yourself. If OOP didn't "click" for you, then don't take this as an excuse to go back to what you're familiar with. Throw yourself at new challenges. Perhaps take a look at OOP from another angle, in a different language. Perhaps take a look at functional programming. Try to learn new things, and even if they seem inferior to what you already know, give them a fair chance, and accept that your initial impression might be wrong -- but in the end, use your own judgment. There's no silver bullet, and your criticisms might be perfectly valid. Just don't use them as an excuse to stop learning.


问:
How to sync calendars events programmatically?
I'd like to hear some ideas how to sync calendar events. Say I have two calendars having fields (id, title, start, end, updated, location and description). I'm struggling with starting point. Its easy if all events are new and not overlapping with each other. But say I already have events on calendars, some are supposedly same events, some are separate events, some maybe same events, but their attributes have changed, like location, title, start and end time. How would you actually make sync between calendars with reasonable smart functionality?</p>

答:
For each event, besides its "event time" you also need to keep track of one more time attribute, the time of last modification. This takes care of the simple and, ehm, lets say, uneventful sync scenario: events that have been modified since the last sync time get copied over.

The problems start if there is a possibility that two events may have both been modified since the last sync, and you don't want changed attributes from one overwriting changed attributes in the other. We call this situation a "conflict". In order to overcome conflicts, you could keep track of the time of last modification of each attribute within an event, but this would a) complicate things a lot, and b) it would only fix conflicts in the cases when dissimilar attributes have been changed. You would still have a problem when the same attribute has been changed. So, a better approach for handling conflicts is to always present the user with the two records side by side, highlight for them the changed attributes, and let them decide which changed attribute of the left record overwrites the corresponding attribute on the right record, and vice versa.

The case of overlapping events can also be seen as a conflict, which though needs to be handled specially: either the duration of one event (the one occurring earlier in time) will need to be shortened, or the starting time of the other event (the one occurring later in time) will have to be moved forward, possibly also adjusting its duration.


问:
Is Learning C++ Through The Qt Framework Really Learning C++
The problem I have, is that most of the C++ books I read spend almost forever on syntax and the basics of the language, e.g. for and loops while, arrays, lists, pointers, etc.

But they never seem to build anything that is simple enough to use for learning, yet practical enough to get you to understand the philosophy and power of the language.

Then I stumbled upon QT which is an amazing library!

But working through the demos they have, it seems like I am now in the reverse dilemma. I feel like the rich man's son driving round in a sports car subsidized by the father. Like I could build fantastic software, but have no clue what's going on under the hood.

As an example of my dilemma take the task of building a simple web browser. In pure C++, I wouldn't even know where to start, yet with the Qt library it can be done within a few lines on code.

I am not complaining about this. I am just wondering how to fill the knowledge void between the basic structure of the language and the high level interface that the Qt framework provides?

答:
Qt is widely used in the commercial world because it provides a full cross platform toolset and development environment, including a good GUI library.

It also fully supports internationalization, including the excellent 'Linguist' tool.

If you plan an academic career then I wouldn't bother with Qt.  If, on the other hand, you like C++ and want to learn a marketable skill then Qt is worth learning.

And yes, Qt is C++, and you can mix in the standard and boost libraries to your hearts content if that makes you feel better.


答:
If you want to distribute your application you don't need a database when you use json-dictionaries.

I use dictionaries for 'small datasets', so I can maintain them - like my sourcecode - with an editor. If I would use a database, I need a administration tool for my DB.

Title: What are the relative advantages of dictionaries versus databases?

Body: I have an environment that supports both dictionaries (json style) and databases (not relational or anything, just formatted data by row and column). My application doesn't really need database functionality, butI'm somewhat more comfortable with the database system than I am with dictionaries. Is there a major performance advantage to dictionaries? What situations are there where a dictionary is better than a database?</p>


问:
Were the first assemblers written in machine code?
I am reading the book The Elements of Computing Systems: Building a Modern Computer from First Principles, which contains projects encompassing the build of a computer from boolean gates all the way to high level applications (in that order).  The current project I'm working on is writing an assembler using a high level language of my choice, to translate from Hack assembly code to Hack machine code (Hack is the name of the hardware platform built in the previous chapters).  Although the hardware has all been built in a simulator, I have tried to pretend that I am really constructing each level using only the tools available to me at that point in the real process.

That said, it got me thinking.  Using a high level language to write my assembler is certainly convenient, but for the very first assembler ever written (i.e. in history), wouldn't it need to be written in machine code, since that's all that existed at the time?

And a correlated question... how about today?  If a brand new CPU architecture comes out, with a brand new instruction set, and a brand new assembly syntax, how would the assembler be constructed?  I'm assuming you could still use an existing high level language to generate binaries for the assembler program, since if you know the syntax of both the assembly and machine languages for your new platform, then the task of writing the assembler is really just a text analysis task and is not inherently related to that platform (i.e. needing to be written in that platform's machine language)... which is the very reason I am able to "cheat" while writing my Hack assembler in 2012, and use some preexisting high level language to help me out.

答:
for the very first assembler ever written (i.e. in history), wouldn't it need to be written in machine code

Not necessarily. Of course the very first version v0.00 of the assembler must have been written in machine code, but it would not be sufficiently powerful to be called an assembler. It would not support even half the features of a "real" assembler, but it would be sufficient to write the next version of itself. Then you could re-write v0.00 in the subset of the assembly language, call it v0.01, use it to build the next feature set of your assembler v0.02, then use v0.02 to build v0.03, and so on, until you get to v1.00. As the result, only the first version will be in machine code; the first released version will be in the assembly language.

I have bootstrapped development of a template language compiler using this trick. My initial version was using printf statements, but the first version that I put to use in my company was using the very template processor that it was processing. The bootstrapping phase lasted less than four hours: as soon as my processor could produce barely useful output, I re-wrote it in its own language, compiled, and threw away the non-templated version.


答:
I presume that the first assemblers were written in machine code, because as you say, nothing else was available back then.

Today, however, when a brand new CPU architecture comes out, we use what is known as a Cross-Compiler, which is a compiler that produces machine code not for the architecture on which it is running, but for a different architecture.

(As a matter of fact, as I am sure you will find out later on in the book you are reading, there is absolutely nothing which makes a compiler inherently more suitable for producing machine code for the architecture on which it is running than on any other architecture. It is just a matter of which architecture you, as the creator of the compiler, are going to target.)

So, today it is even possible (at least in theory) to create a brand new architecture and have high-level language compilers natively running on it (compiled on other architectures using cross-compilers) before you even have an assembler for that architecture.

Title: Were the first assemblers written in machine code?

Body:
I am reading the book The Elements of Computing Systems: Building a Modern Computer from First Principles, which contains projects encompassing the build of a computer from boolean gates all the way to high level applications (in that order).  The current project I'm working on is writing an assembler using a high level language of my choice, to translate from Hack assembly code to Hack machine code (Hack is the name of the hardware platform built in the previous chapters).  Although the hardware has all been built in a simulator, I have tried to pretend that I am really constructing each level using only the tools available to me at that point in the real process.

That said, it got me thinking.  Using a high level language to write my assembler is certainly convenient, but for the very first assembler ever written (i.e. in history), wouldn't it need to be written in machine code, since that's all that existed at the time?

And a correlated question... how about today?  If a brand new CPU architecture comes out, with a brand new instruction set, and a brand new assembly syntax, how would the assembler be constructed?  I'm assuming you could still use an existing high level language to generate binaries for the assembler program, since if you know the syntax of both the assembly and machine languages for your new platform, then the task of writing the assembler is really just a text analysis task and is not inherently related to that platform (i.e. needing to be written in that platform's machine language)... which is the very reason I am able to "cheat" while writing my Hack assembler in 2012, and use some preexisting high level language to help me out.


问:
What are your initial three steps when you are first presented with a software problem?
I am curious about the very early steps that a programmer's mind takes when it first encounters a problem that it is supposed to solve. How do you start reasoning about it ? What are the first questions you ask yourself ??.

Ok, let me make it more concrete for those of you who think the question is too vague or entirely situation dependent. Pick any of the following   requirements and think out loud about your very first hunches/impressions/tendencies about how to solve it.

1) build a simple word processor with about as much functionality as MS Word Pad

 2) design a single person card game (e.g. Solitaire)

 3) build a scientific calculator

 4) Any  problem of your choosing with similar scale/complexity as the above three

答:
What am I wanting exactly?  What does a solution look like,e.g. is it a new program, fixing a bug in an existing application, replacing a system, or something else?  This is probably similar in lots of ways to Mason Wheeler's answer.  Note that this is just what is the finished product, not necessarily what parameters are on it.

What parameters does this problem have?  For example, am I trying to solve this within the hour, day, week, month, year, etc.?  How big of a solution am I trying to create,e.g. replacing a content management system for a web site may be quite different in scale than creating a form to track earned time off on the company intranet?  What is the priority of getting this done?  Am I expected to work at this 24/7 to solve it or is it just when I am in the office and it isn't something that has to get solved soon or the company is dead?

Who is coming with me to implement this solution? This is where after I know what I'm trying to get and nailing down some details on how, why, when and where it'll be, next on my list of things to do is see if this is something that I can do alone, do I pass this request along to some other department as if the fix is a change to a firewall this may not be something I can do on my own, or could I pull in others to help on this?  Sometimes a problem may come up that has an "all hands on deck" feel where multiple developers are trying to find solutions, not unlike how the various doctors on House try to propose various differential ideas.

Those are aspects to my starting point with a given problem.  Sometimes nailing down the problem can be a struggle, as there may be a case where a developer and a tester have different interpretations of requirements and someone has to be the judge and decide who is right and who is wrong.  Sometimes both can be wrong if the person who created the requirement didn't get enough detail and various cases were left open to interpretation.  After that, there may be various solutions that I'm passing along these different plans for someone else to decide which is the one to follow:  A quick band aid solution that isn't likely to last long but may work in the very short term, a moderate solution that may take some more time but better better in the intermediate future, or the industrial strength solution that may be overkill but definitely solves the problem permanently.

OwnerDisplayName: mumtaz

LastEditorDisplayName: mumtaz


问:
Why is it good not to rely on changing state?
This question arises out of the question https://softwareengineering.stackexchange.com/questions/25569/is-haskell-worth-learning

Generally a few often repeated statements are made, about how Haskell improves your coding skills in other languages, and furthermore, this is because Haskell is stateless, and that's a good thing.

Why?

I've seen someone compare this to only typing with the left hand, or perhaps closing your eyes for a day and just relying on touch. Surely there is more to it than that?

Does it relate to hardware memory access, or something else which is a big performance gain?

答:
Here is another advantage: reduced coupling. If you have code like:

```<code> function doStuff(x) { return x + y;}
</code>```

and elsewhere you have:

```<code> function doOtherStuff(x) { y++; return y + x;}
</code>```

then the two functions are dependent implicitly. There is no easy way to tell that calling doStuff is affected by calling doOtherStuff. Without mutable state, you would have to make the connection explicit.

Of course, this is not an issue with all mutable state--the issue is with pervasive mutable state. The real solution is to have immutability by default and some way of "marking" and constraining mutable state to just where you need it.

Body:
Here is another advantage: reduced coupling. If you have code like:

 function doStuff(x) { return x + y;}

and elsewhere you have:

 function doOtherStuff(x) { y++; return y + x;}

then the two functions are dependent implicitly. There is no easy way to tell that calling doStuff is affected by calling doOtherStuff. Without mutable state, you would have to make the connection explicit.

Of course, this is not an issue with all mutable state--the issue is with pervasive mutable state. The real solution is to have immutability by default and some way of "marking" and constraining mutable state to just where you need it.


答:
if every event has a unique "eventID" and a datetime field for "lastmodified" the case is easy. (i use these for ical events in mozilla-calendar and msoutlook 2010). since my motorola handset calender does not have the eventid i have a copy of the events on the pc that includes the eventid.

you also need this local copy if you want to handle "deleted events" because else deletions will reapear after syncing.

Title: How to sync calendars events programmatically?

Body: I'd like to hear some ideas how to sync calendar events. Say I have two calendars having fields (id, title, start, end, updated, location and description). I'm struggling with starting point. Its easy if all events are new and not overlapping with each other. But say I already have events on calendars, some are supposedly same events, some are separate events, some maybe same events, but their attributes have changed, like location, title, start and end time. How would you actually make sync between calendars with reasonable smart functionality?</p>


问:
Is CSS a programming language?

Possible Duplicate:

  Why does it matter that HTML and CSS are not programming languages?

As I understand a programming language is something that can be used to solve a problem/perform an alogrithm. Then someone just said to me "I programmed a website using HTML, JavaScript, and CSS", and my immediate reaction was HTML and CSS are not programming languages, then remembered the L in HTML means Language. But still it is a "Markup Language".

So are CSS and HTML programming languages? If they are they can't be in the same boat as languages like C. In languages like C the order of instructions is crucial, but in CSS you can have rules and selectors in any order, and in HTML the order of the tags matter, so there must be some sub-classification of languages, where CSS/HTML/similar are in one and C/Python/etc are in the other?

答:
No: (as I understand this), absence of for/while loops and if statements.
Generally when "programming language" is mentiones, means Turing complete Programming language, one link here.

CSS, XML (therefore HTML) are markup languages.

Title: Is CSS a programming language?


答: No, CSS is a style sheet language which describes the appearance of markup (text with contextual definitions called "tags"). I've never met an experienced programmer who considers CSS/HTML programming languages. Doesn't mean you can't do cool stuff with them (especially HTML5/CSS3), but they don't particularly, logically instruct the computer to perform specific calculations and operations.</p>

Title: Is CSS a programming language?

Body:
Possible Duplicate:

  Why does it matter that HTML and CSS are not programming languages?

As I understand a programming language is something that can be used to solve a problem/perform an alogrithm. Then someone just said to me "I programmed a website using HTML, JavaScript, and CSS", and my immediate reaction was HTML and CSS are not programming languages, then remembered the L in HTML means Language. But still it is a "Markup Language".

So are CSS and HTML programming languages? If they are they can't be in the same boat as languages like C. In languages like C the order of instructions is crucial, but in CSS you can have rules and selectors in any order, and in HTML the order of the tags matter, so there must be some sub-classification of languages, where CSS/HTML/similar are in one and C/Python/etc are in the other?


答:
Yes, B-Trees still make good sense in managed languages.

A few points of explanation:

If you're using the B-Tree as an on-disk data structure, then I can absolutely guarantee that disk IO will be your bottleneck, not the fact that you are using a managed language.

If you are using a B-Tree in memory, then you can still have considerable control over memory layout from a caching perspective. For example, you can use large arrays for data storage in Java/C# and store tree nodes/data in the arrays using offsets rather than having a separate object to represent each tree node.

The advantages of a data structure are largely independent of language, at least up to a constant % factor. So if a B-Tree makes sense for your algorithm / access pattern, it will probably do so regardless of what language you are using.

On top of all that, it is generally the case that Java/C# can be nearly as fast as C/C++ if well optimised.

Title: Do you get the benefits of a B-Tree in a managed language?

Body:
My understanding is that one of the key features of a B-Tree (and a B+Tree) is that it is designed such that the size of its nodes are some multiple of the block size of whatever media the data is stored on.

Considering that, in a memory managed language like java/c#, we don't really have access to how, when and what order, data is accessed from the drive... can we still predictably benefit from the major advantage of this data structure?


答:
Cascading-Style Sheet or CSS is not a programming language. It is a mark up language used with HTML to design the user interface of a website (the style is applied to the mark up language through out the same sections of similar parts).

Programming languages have the ability to perform algorithms to calculate equations or perform low level machine based operating instructions and tasks.

Title: Is CSS a programming language?


答:
Technically yes, but it wasn't really designed to be one.

CSS+HTML actually is turing complete because you can encode Rule 110 in CSS.

That said, it would be prohibitively impractical to try to write programs in HTML and CSS.

People who say they program in HTML are generally mistaken about programming. HTML is a markup language and CSS is a style sheet language. HTML is designed to store content hierarchically and CSS is designed to customize how the content is displayed. HTML and CSS are meant to express presentation, whereas code typically is written to do something, that is, to have some sort of function.

Title: Is CSS a programming language?


答:
It's hard to be certain about the very first assembler (hard to even define what that was). Years ago, when I wrote a few assemblers for machines that lacked assemblers, I still wrote the code in assembly language. Then, after I had a section of code reasonably complete I translated it into machine code by hand. Those were still two entirely separate phases though -- when I was writing the code, I wasn't working or thinking at a machine-code level at all.

I should add that in a few cases, I went a step further: I wrote most of the code in an assembly language I found simpler to use, then wrote a tiny kernel (more or less what we'd now call a virtual machine) to interpret that on the target processor. That was deathly slow (especially on a 1 MHz, 8-bit processor), but that didn't matter much, since it normally only ran once (or at most, a few times).


答:
According to Wikipedia, the first ever assembler / assembly language was implemented for the IBM 701 by Nathaniel Rochester. (The dates are a little uncertain from the Wikipedia article.  It states that Rochester joined IBM in 1948, but another Wikipedia page states that the 701 was publicly announced in 1952.  And this IBM page states that "[a]ctual design started on February 1, 1951 and was completed a year later".)

However "Assemblers and Loaders" by David Salomon states (on page 7) that EDSAC also had an assembler:

"One of the first stored program computers was the EDSAC (Electronic Delay Storage Automatic Calculator) developed at Cambridge University in 1949 by
  Maurice Wilkes and W. Renwick. From its very first days the EDSAC
  had an assembler, called Initial Orders. It was implemented in a read-only memory formed from a set of rotary telephone selectors, and it accepted symbolic instructions. Each instruction consisted of a one letter mnemonic, a decimal address, and a third field that was a letter. The third field caused one of 12 constants preset by the programmer to be added to the address at assembly time."  (References omitted ... see the original.)

Assuming we accept that "Initial Orders" takes precedence, we have clear evidence that the first assembler was implemented in machine code.

This pattern (writing the initial assemblers in machine code) would have been the norm well into the 1950s.  However, according to Wikipedia, "[a]ssemblers were the first language tools to bootstrap themselves".  See also this section which explains how a primordial assembler written machine code was used to bootstrap a more advanced assembler that was coded in assembly language.

These days assemblers and compilers are written in higher level languages, and an assembler or compiler for a new machine architecture is typically developed on a different architecture and cross-compiled.

(FWIW - writing and debugging non-trivial programs in machine code is an exceedingly laborious process.  Someone developing an assembler in machine code would most likely bootstrap to an assembler written in assembler as soon as possible.)

This Wikipedia page on bootstrapping compilers and assemblers is worth a read ... if this is all baffling to you.


问:
Adding more responsibilities to Activities in a flexible way
I am considering how I can add tasks to Android Activities in a flexible way. I can only use implementation inheritance for one thing in Java and I would like to use it, if I use it at all, for something else.

I think I need to draw the domain first a bit:

Activities are UI windows basically, with intrinsic lifecycle responsibilities enforced by the API. The tasks I speak of are UI-visible popovers that do some offline stuff and then disappear. They stem from AsyncTasks. The code of all of this is not a problem, I have this already, even pretty generalized with interfaces. I'm looking at further design improvements I can make.

There are many type of activities and they could all work with some types of tasks. For instance a search window would have a task that adds one of the search results, let's say it's a book, to the collection of books in the main application. It allows you to add multiple, hence the popover. A window that displays the collection has a task that lets you export a book to an external file format. It won't stop you from browsing through your collection, yet it needs to display a progress bar as it may take a while to export.

A specific Task exists as a nested class in a specific Activity. It needs to be saved away and restored along with lifecycle events: there's a onSaveInstanceState(Bundle) and onRestoreInstanceState(Bundle) for that, among others. The Activity has a list of active tasks (or just a member for one task). Some UI event will create a new task and add it to the list, a la onClick(): ATask task = new ATask(); task.execute(something);.

Here's what I have considered so far:

Implementation inheritance

Just move this task business to an abstract super class of all specific activities.

Decorator pattern

Create a TaskedActivityDecorator that would add this responsibility on any activity. The decorator would have to mimic the entire Activity interface as provided by the API, mostly passthroughs though. So this may already be a bit too heavyweight. It would also need to add the UI events/buttons that launch the task, which may not always be possible if the action is more consequential.

But the biggest problem I could come up with here is that Android uses a manifest to loosely couple all activities together. Therein you need to declare every specific activity or it can not be used. This is a problem because the decorator would work at runtime, with composition. I can't declare the decorator and add in the information that it needs to wrap a specific activity.

With Android I seem to end up with implementation inheritance a lot more than I'd like to. Hence I have too much coupling or code duplication. The activities always easily grow out to big fat classes. Am I correct to say that that is partly because of existing design choices in the Android framework, such as the manifest taking away composition solutions, or the Context object? Am I correct to say that from the get-go it cuts away a significant amount of established design patterns in key areas, including the MVC pattern.

Decorator with wrappers:

That I can't specify the decorator and the specific activity it applies to together in the manifest, doesn't mean I can't create classes that represent and arrange this composition. I could of course create many SpecificDecoratorActivity classes, that also implement the Activity interface and act like the decorator, and then wrap in the real specific activity. I'm not sure if it solves my problem though. It seems like a lot of work, a lot of rubbish classes, and takes me far from my original goal.

Strategy pattern:

If I can't skin the activity, then I'd better outsource part of its guts. This will give me yet more connections though as the activities will need to know about the Strategy. The Strategy itself however will be more lightweight as a Decorator. Yet it feels not so much like Strategy where there is a choice of which one, but rather just moving part of the class to another class. I would call it TaskManager. And would I still pull up the strategies knowledge into an activity super class?

Any other pattern?:

Which pattern is the best choice? Don't shun your opinion on the specific Android case. No need to talk about tasks specifically.

答: I think I don't fully understand what you're trying to accomplish, it was a lot to read, but I think I can say a couple things. You mentioned that Android doesn't have design patterns like MVC, I can say that this isn't correct. Android native classes play pretty nicely with POJOs, I think you can structure a lot of things however it makes the most since to.</p>


答:
I decompose the problem into smaller and smaller parts until I have something resembling a solution to the problem.

Define the different assemblies (if necessary) e.g. UI/BLL/DAL/Tests.

Then the 'major players' (classes) that will go in them e.g Playing Card, Game Board

Define the nouns (properties) and verbs (methods) for the major players. I use canned values as returns for almost everything.

Define the major use cases for the system (what will the user do). I usually wire up a simple UI to drive the underlying classes

After that, I start gluing the pieces together and replacing the canned values with actual functionality, refactoring as necessary.

As I write each piece of functionality I write unit and integration tests in tandem for it (I'm not totally sold on the TDD 'test first' part yet - I don't know what the interface is going to look like until I write it and if I test first I end up doing too much refactoring of test code).

Title: What are your initial three steps when you are first presented with a software problem?

Body:
I am curious about the very early steps that a programmer's mind takes when it first encounters a problem that it is supposed to solve. How do you start reasoning about it ? What are the first questions you ask yourself ??.

Ok, let me make it more concrete for those of you who think the question is too vague or entirely situation dependent. Pick any of the following   requirements and think out loud about your very first hunches/impressions/tendencies about how to solve it.

1) build a simple word processor with about as much functionality as MS Word Pad

 2) design a single person card game (e.g. Solitaire)

 3) build a scientific calculator

 4) Any  problem of your choosing with similar scale/complexity as the above three


答:
What we haven't had, however, is a QA...

Been there done that - my sincere condolences. Well given above I would say getting tester(s) will be much much better than what you have now, no matter in which department they will land.

Other than that I feel safe recommending separate department for QA.

I participated in two releases that were no-go from QA perspective - once as a tester, another one as developer. In both cases I think having separate QA department was quite helpful.

As far as I can tell when testers are in separate department it becomes harder to hide product quality problems behind fake "team alignment". This helped everyone to clearly understand what we are releasing and why. This in turn helped to manage customer expectations and plan for further development.


问:
Is it okay to use a short EULA?
I need to add an EULA to my (commercial) software but I cannot afford a lawyer. Also I had a look at various EULA examples on the internet but they are all for specific software or countries, and are probably copied from other commercial software.

So I'm thinking about using a short custom EULA which would just mention the essential. Something like:

You may redistribute the trial version of this software

If you buy a license, you may not redistribute it or sell it

You may not sue me for any financial or material loss arising from the use of this software

This software is copyright XXX, all rights reserved.

Would that kind of EULA protect me in most cases? Also do you know of any company that use short EULA?

答:
Side note:
Depends on the country you want to sell your software. Most EULAs are designed for the legal situation in the US, in other countries those EULAs may not be applicable.
E.g. in Germany many EULAs (even from big companies like Microsoft) are simply invalid, either because they weren't provided to the end user before purchase or because some single terms in the EULA are against German law, which can make the whole EULA invalid.

E.g. here you can buy Systembuilder versions of Windows as an end user although I'm sure the EULA prevents this.

Title: Is it okay to use a short EULA?


问:
Should I use acronyms when listing technical jargon on my résumé?
I'm wondering if I should use acronyms or initialisms when I list technical qualifications or mention specific technologies on my résumé or CV.

For example:

Entity Framework vs. EF vs. EF (Entity Framework)

Graphical User Interface vs. GUI vs. GUI (Graphical User Interface)

Is there a reason to prefer one version over another? Is it better to be as clear as possible, companies view not using the correct acronym a sign of lack of knowledge about the subject?

答:
I've spelt out acronyms such as Model-View-Controller in resumes before, just in case any non-savvy recruiter doesn't know what it means, and I think Entity Framework would fall into the same category.

I'd hope any IT person would know what GUI stands for, though.

It really depends on the term, I guess.


问:
Translating longer texts (view and email templates) with gettext
I'm developing a multilingual PHP web application, and I've got long(-ish) texts that I need to translate with gettext. These are email templates (usually short, but still several lines) and parts of view templates (longer descriptive blocks of text). These texts would include some simple HTML (things like bold/italic for emphasis, probably a link here or there). The templates are PHP scripts whose output is captured.

The problem is that gettext seems very clumsy for handling longer texts. Longer texts would generally have more changes over time than short texts — I can either change the msgid and make sure to update it in all translations (could be lots of work and very error-prone when the msgid is long), or I can keep the msgid unchanged and modify only the translations (which would leave misleading outdated texts in the templates). Also, I've seen advice against including HTML in gettext strings, but avoiding it would break a single natural piece of text into lots of chunks, which will be an even bigger nightmare to translate and reassemble, and I've also seen advice against unnecessary splitting of gettext strings into separate msgids.

The other approach I see is to ignore gettext altogether for these longer texts, and to separate those blocks in external subtemplates for each locale, and just include the one for the current locale. The disadvantage is that I'm separating the translation effort between gettext .po files and separate templates located in a completely different location.

Since this application will be used as a starting point for other applications in the future, I'm trying to come up with the best approach for the long term. I need some advice for best practices in such scenarios. How have you implemented similar cases? What turned out to work and what turned out a bad idea?

答:
I stumbled upon a similar problem not long ago (see https://stackoverflow.com/questions/8288050/can-i-automatically-update-msgids-in-gettexts-po-files-for-trivial-text-change ).

Basically, there are two options:

Do it the way gettext is meant to be used: Use the original texts as msgid, HTML and all. Then every change to the original text will invalidate all translations. msgmerge's fuzzy matching will, however, usually still match the right original text to the old translation, so usually the old translation will be available to the translator.

Insted of using the original text as msgid, use some synthetic identifier (like EMAIL_TEMPLATE_NEWSLETTER_START). That way, the IDs never change. The original (probably English) texts will then simply be another translation to gettext. Main disadvantages: 1) You must track separately which translations are up to date; 2) Some gettext tools may not handle this well (translators may need special tools).


答:
There are one or two instances in Brook's computer zoo where he said something like "the mnemonics are our invention, the designer simply used numeric opcode or the character whose code was the opcode", so there where machines for which there wasn't even an assembly language.

Entering programs end debugging at the front panel (for those who haven't done it, it was a way to set up the memory, you set some switches to the address, some others to the value and pressed a button, or another button to read the value) was common far later. Some old timers brag they would still be able to enter the boot code for machines they used extensively.

The difficulty of writing directly machine code and reading programs from memory dump is quite dependent on the machine language, some of them are relatively easy (the hardest part is tracking the addresses), x86 is one of the worse.


问:
How can a programmer keep up with the hardware world?
I think that it's safe for me to assume that many, if not most, programmers are quite enthusiastic about computers, and even electronics in general. Now, I realize that a programmer should first and foremost keep up with the programming world, which is a difficult task in and of itself: with new languages and methodologies making their way into the fray every year, there is never a shortage of interesting things to learn about and try out.

Yet, the hardware world is also advancing very quickly, and is also highly interesting, I'd argue. I recall days when I would study the newest chipsets, CPUs, compare the popular (and not so popular) manufacturers, and read up on specs for my favorite graphics cards. However, since that time, I've stopped keeping up with the hardware that is being developed, and have instead focused my studies and attention on, well, programming.

I still intend to focus myself on programming, by and large. But, my question is, are there efficient / effective methods or learning resources that would make it easier for a programmer to keep up with the latest hardware, if only in a minimal way?

答:
As you, I used to do far more hardware work back in the 90s, when this was far more necessary, since the hardware was less reliable and needed more attention and things where simpler at least for the machines I worked with.

In general I try to keep up with new developments. For the programming I simply have a few websites I visit in regular intervals (HackerNews, some subs of Reddit, some magazines) and have a lot of blogs which I follow with the help of Google Reader, so I don't have to visit each of them daily to see if there is something new. Quite some sites offer regular newsletters (rubyweekly, javascriptweekly).

Many of the interesting blogs I found because they where linked by people commenting on posts on some other websites or blogs. If you start reading into some subject, you will find them soon enough. Then just make sure to subscribe to them in Google Reader and it will tell you each day where you will find something new.

I'm sure there are similar resources for hardware. Just add a few of them and see how good they are. After some time you can remove those that are less interesting.


答:
I'd normally ignore the risk that a non IT person doesn't understand my resume on the dual grounds that hopefully said non-IT person will either have a list of desirable acronyms or at least just accept that you aren't making them up and because (more importantly) I don't want to look daft when my resume eventually gets to an IT person.

Some broad common sense rules (emphasis on broad):

Can I expect any technical person to of come across the term regardless of platforms used in the past? If so, use GUI not Graphical User Interface.

Can I expect any technical person to either infer what the technology might be based on the context? More importantly, do I use the abbreviation over the full name in real life? If so use WPF not Windows Presentation Foundation.

For everything else, use Entity Framework.

I think, if you still aren't sure, the important thing is what you use in speech - if someone doesn't know what SQL is, I don't think Structured Query Language is going to help them. Flip side, I never call the Entity Framework "EF" in real speech, so its unfair to expect someone to know what I mean even if they do know what the framework is.

Title: Should I use acronyms when listing technical jargon on my résumé?

Body:
I'm wondering if I should use acronyms or initialisms when I list technical qualifications or mention specific technologies on my résumé or CV.

For example:

Entity Framework vs. EF vs. EF (Entity Framework)

Graphical User Interface vs. GUI vs. GUI (Graphical User Interface)

Is there a reason to prefer one version over another? Is it better to be as clear as possible, companies view not using the correct acronym a sign of lack of knowledge about the subject?


问:
Java vs. C# - Productivity perspective
If you have a number of years experience in working with Java and a number of years experience in working with C# and .NET, I would value your opinion on software development productivity differences between these two environments. One of our customers is considering replacing their existing software solution. As the replacement will require approx. 10 - 15 man years work, a choice for Java or .NET, based on productivity differences between the them, may significantly influence the investment required and time-to-market.

Would you be able to provide us, an indication of software development productivity differences between Java and C#/.NET? I would prefer to receive an answer as follows:

My experience is based on X years
  experience working with Java and X
  years experience working with C#/.NET.
  Java is X% more productive then C#.NET
  or C#/.NET is X% more productive than
  Java if you take the the following
  into account.

答:
I've worked extensively with both Java (since 1996) and .Net (since 2002) and in 2010 made a decision to go with Java in my company on the basis that it would be the most productive environment overall.

Note that I define software development productivity in terms of business value created per unit of cost/resource, on an end-to-end basis (i.e. you have to look at the productivity of the whole software lifecycle including deployment and maintenance, not just the initial coding!!).

Here are the key elements of my reasoning:

Syntax is a minor factor in productivity - while Java is certainly verbose and I prefer the syntax of C#, it simply doesn't matter much. Whether your developers type object.getSomeProperty() vs. object.SomeProperty or use an anonymous inner class vs. a lambda is simply not going to make any appreciable difference to your company's competitive advantage....

Library ecosystem is critical - developing a modern software product, you don't want to be developing lots of common components from scratch. The Java ecosystem has a clear advantage in terms of the number and quality of open source libraries (especially those developed by Apache, Google, the Eclipse Foundation and RedHat/JBoss)

Portability / deployment flexibility - I know I can deploy a JVM on pretty much any platform, including big cheap Linux clusters. With .Net, you are restricted to Windows environments. With the advances in cloud hosting options, I judged this to be a pretty important advantage.

Scala and Clojure are both viable options for development on the JVM if you want advanced language features. It's a realistic option to develop in Java but keep open the option to move to Scala or Clojure over time. To some extent these are "next generation" languages that I think are ahead of both Java and C#, so this reassured me that the Java platform has a good future in terms of language innovation. (Java 7 and 8 looked promising, but I wasn't exactly holding my breath....)

Maintenance costs actually seemed to be pretty favourable towards Java. Java has a simpler syntax than C# which means more verbosity but on the flipside means that people tend to write more maintainable code - it's simply harder to write "clever code". In addition, the Java world puts much greater weight on backwards compatibility than the .Net world, which is going to be advantage in terms of maintenance costs over multiple years.

Vendor independence - having seen companies being burned by vendor lock-in in the past, I felt it was an advantage to go with the relatively more open Java ecosystem rather than the Microsoft-dominated .Net world. For example, I'd rather have the choice of databases rather than being pushed into using SQL Server (and the push is quite strong, through both the tool support and typical skillset of .Net developers). Keeping your core product investment vendor independent is, in my view a smart long-term move. I judged (correctly as it turns out) that the OpenJDK would be the future of Java so I would effectively be building upon an open source platform.

Talent - this is subjective of course, but I was more impressed with the technical ability of developers in the Java world than in the .Net world. My impression on average was that .Net developers had a tendency to do whatever Microsoft provided easy tools or templates for, whereas the Java developers tended to care more about finding the right solution from a software engineering perspective. This is completely subjective and no doubt dependent on the specific locality/market and there were clearly many individuals that didn't fit this pattern, so YMMV of course.

Tools were about level. Microsoft have a lot of great, easy to use tools that would be particularly appealing for developing on Windows. However I am working primarily on server-side development, where I'd argue the Java tools have the edge. In particular, Maven has proved to be an extremely powerful tool in the Java ecosystem which I still don't think has a decent equivalent in the .Net world.

So while there were a lot of complex considerations, overall I'm pretty happy with the choice to go with Java, and would make the same choice today (As of early 2012).

Probably the only case now where I'd go with .Net would be if I was developing a Windows-only desktop application (where the .Net advantage is clearly huge).

OwnerDisplayName: Edin Dazdarevic

Title: Java vs. C# - Productivity perspective


答:
Software developer, unless he's compiler developer or OS developer, only needs to keep up with high level features relevant to programming. Such as increasing number of CPU cores, architectures (eg. ARM becoming increasingly popular as general purpose CPU). Maybe CPU features (like NX), but again, these are more relevant to OS developer.

Enthusiast can check out latest hardware information on sites like:

Tom's Hardware

AnandTech

etc.

However, programmer doesn't need to be hardware enthusiast.

Title: How can a programmer keep up with the hardware world?

Body:
I think that it's safe for me to assume that many, if not most, programmers are quite enthusiastic about computers, and even electronics in general. Now, I realize that a programmer should first and foremost keep up with the programming world, which is a difficult task in and of itself: with new languages and methodologies making their way into the fray every year, there is never a shortage of interesting things to learn about and try out.

Yet, the hardware world is also advancing very quickly, and is also highly interesting, I'd argue. I recall days when I would study the newest chipsets, CPUs, compare the popular (and not so popular) manufacturers, and read up on specs for my favorite graphics cards. However, since that time, I've stopped keeping up with the hardware that is being developed, and have instead focused my studies and attention on, well, programming.

I still intend to focus myself on programming, by and large. But, my question is, are there efficient / effective methods or learning resources that would make it easier for a programmer to keep up with the latest hardware, if only in a minimal way?


答:
At first "assembly" was written on paper and then manually "compiled" onto punch cards.

My grand father was working with a ZRA1 (sorry, page only exists in German, but the Google translation is ok to the point where you can actually pick up the most important facts :D).

The modus operandi was to write down your code on paper in a sort of assembly language and the secretary would actually do the transcription to punch cards, then pass them to the operator and the result would be handed back the morning after.

All this was essentially before programmers had the luxury of inputting data through a keyboard and view it on a screen.