问:
Resources on learning to program in machine code?
I'm a student, fresh into programming and loving it, from Java to C++ and down to C. I moved backwards to the barebones and thought to go further down to Assembly.

But, to my surprise, a lot of people said it's not as fast as C and there is no use. They suggested learning either how to program a kernel or writing a C compiler. My dream is to learn to program in binary (machine code) or maybe program bare metal (program micro-controller physically) or write bios or boot loaders or something of that nature.

The only possible thing I heard after so much research is that a hex editor is the closest thing to machine language I could find in this age and era. Are there other things I'm unaware of? Are there any resources to learn to program in machine code? Preferably on a 8-bit micro-controller/microprocessor.

This question is similar to mine, but I'm interested in practical learning first and then understanding the theory.

答:
People don't program in machine code (unless they are masochistic). They use (or develop) tools to generate machine code (compiler or assembler, including cross-development tools), or perhaps libraries generating machine code (LLVM, libjit, GNU lightning, ....). So resources about machine code generation, compilation, optimizers, and micro-architectures are also relevant.

And very often, a good optimizing compiler generates better machine code than you could do. You'll probably don't be able to write a 200 line assembler code better than a good optimizer.

If you want to understand machine code, learn assembly first. It is very close to machine code. Use it wisely, only for things you cannot code in C (or in some higher-level language, like Ocaml, Haskell, Common Lisp, Scala). A good way is often to use asm instructions (notably GCC extended assembly feature) inside a C function. Reading the assembly code (generated by gcc -S -O2 -fverbose-asm) can also be helpful.

The Linux Assembly HowTo is a good thing to read.

Current processor's instruction set architecture (i.e. the set of instructions understood by the chip) are quite complex. Common ones are x86 (a typical PC in 32 bits mode), X86-64 (a desktop PC in 64 bits mode), ARM (smartphones, ...), PowerPC etc. They are all quite complex (because of historical and economical reasons). Perhaps learning first an hypothetical instruction set like e.g. Knuth's MMIX is simpler.


问:
Comparison of IDEs for C++ and C development on Linux: KDevelop, Eclipse, NetBeans, CodeBlocks and Anjuta
I'd like to note your experience of full scale IDEs on Linux.

I personally work mostly with vim, however other programmers would like
to see a real IDE. So I'd like to hear your personal opinion about different
IDEs and comparison between them, in following context:

C++ and maybe some C development (not Java, Python and other stuff)

Server side programming (no need for GUI development)

Working on Linux not "cross-platform" development.

Opinion needed regard:

How stable is it? If IDE crashes I don't need it.

Comfortable to use.

Powerful for debugging.

Integration with various build systems

Scalability over huge projects (projects of hundreds thousands of lines of code)

I used to work with KDevelop and it was very nice IDE and seems that KDevelop 4 is a huge progress. It seems also that many rather use Netbeans and Eclipse.

答:
I mainly work with Eclipse.
Used KDevelop with a great satisfaction for years, but now I work on multi-language projects (C, C++, PHP, Java, Python, Database, Web, etc).

Adavantages of Eclipse: lot of tools for about everything (including version control); works very well for syntax check, and auto-completion. Good job when compiling/building/debug. It is multi-platform (Linux, Windows, Solaris, etc)

Disadvantages: some functions or settings are a nightmare (for instance, when you have to deploy the project from your workstation to the server, Eclipse keeps a sort of cache, and if it thinks that the file on the server it's 'up to date', the file is not overwritten).
Eclipse is huge, chokes most of your CPU-Power and drains all your memory. More info at http://www.ihateeclipse.com.

KDevelop is fast, and great for C/C++ and KDE/Qt projects, but lacks of some functions like support for Mercurial (KDevelop 3.3.4, don't know for newer versions).

ContentLicense: CC BY-SA 3.0


问:
How do I create a potential shippable product (PSP) at the end of a sprint?
I'm running a team of 4 developers and 2 testers and trying to abide by the Scrum principle of creating a PSP with every sprint. That means I need to create a potential release with all the user stories that got to Done and store it on some publish server for the PO to do with as they please.

My problem is how to technically create the build when some stories are not at Done at the end of the sprint? The code is checked in, but didn't completely pass testing.

If I only check-in code that is Done, i.e. code complete-reviewed-tested, I run in to the possibility of diverging code bases and merges that may be disastrous. For instance Developers A and B work on different features that modify assembly X. Dev A finishes coding, pushes assembly X to test. The next day Dev B finishes coding and pushes assembly X to test. Feature A comes back with bugs, feature B is perfect. Oops, sprint is over. Now, how do I create a PSP with feature B but not A?

答:
The key is to not allow code to "break the build". In other words do not check in code that doesn't pass testing. If you run a nightly automated build/test cycle this should all be automated for you.

Code which fails would still be stored in the repository as a branch, it would just not be part of the PSP.

In particular you should make use of continuous integration practices and a source code control system like Mercurial (KILN) that are designed to support this.


问:
How should I introduce a coding standard to my team?
First a bit of background:  My current development manager is taking another opportunity the end of this week, leaving our team with four fulltime developers, a part-time intern and a web designer (who is technically part of Marketing, not AppDev).  At this time we aren't promoting or hiring a new manager.

The previous manager never would take the time to come up with a set of coding standards to adhere to (to put this in perspective: My one-year anniversary at this job is in two weeks and I've been talking to him about standards since I started).  Due to this, all of us four developers write code our own way: Some of us follow the Microsoft naming conventions for .NET, some use Hungarian notation, some use a mix (e.g. mixing PascalCase and camelCase for parameter names), and it's entirely random when you open a code file what standard it will follow - about the only thing consistent is that braces are on separate lines.

Two out of my three co-workers have approached me to create a standard coding document that we can use and enforce moving forward (although I am technically not the most senior developer, the fourth developer having been here for several years, two co-workers and the intern look to me for advice/guidance but we do not have a team lead).  I have been meaning to do this for a while but the now-departing manager would always put it on the backburner; his departure now gives us a chance to take some time and configure things correctly to facilitate a proper software environment and not the rushed hodgepodge we currently have.

How should I go about doing this and introducing this standard to my team without causing friction?  I don't want to make it look like I'm "taking over", although were I offered the manager position I would accept it.  As I said two out of three other developers are on board with me creating one, but the fourth (the true "senior" in length of time) may or may not accept it.  I plan to start with the .Net conventions from Microsoft (e.g. do not use Hungarian Notation), add some personal preference (e.g. _camelcase for fields) and specifically call out certain strange practices we use here as not to be used (e.g. naming a class with an underscore at the start), but what else should I include?  I don't want to get into architectural guidelines as that will cause friction and we have a very large, and smelly, existing codebase that wouldn't adhere to it, and we're nowhere near at the point of coming up with a refactoring strategy.

To summarize:  Beyond basic naming conventions what, if anything, should I include in a coding standards document (examples would be great - I haven't managed to find any concrete examples of what such a document should look like), and how should I present it to my team without sounding like the new dictator.

答:
From a technical viewpoint:

Point out the inconsistencies that are really a problem for the team and define coding rules for solving these problems.

From a relational viewpoint:

If you want to get the senior involved, get some inspiration from his own coding conventions.


问:
How to : Nextag and such other dynamic data pulling website
Yesterday, I came across Nextag which is a website for comparing prices of various products from different retailers. Is this site automated?

Can the process of data pulling from various sites can be automated for comparison with each other. I tried understanding a hell lot, but could not realize this fact and now think that they ought to be manually managed because on every other retailer site, the product name was different and it was very hard to recognize a similarity for a specific product.

I have made such a system in which one can add a product and then add the respective retailers and their pricess. Every thing is manual in here. Today, I will be entering the data into the system, but thought it would be better to know if there is a way to automate this thing. Or I am going the right way as there can't be an automation for such system, because the data has no similarities.

答:
While your question appears to be programing related, its answer is more business related. Since i know a thing or two about such sites let me explain things in general.

Such "price engines" are automated, but data is provided by retailers themselves. Why? Just imagine that you crawl some retailer website every other day and that they decide to change price just after you have finished crawling. What is going to happen (sooner or later) is that customers will be disapointed when they figure out something is out of stock or has a different price. They will assign all the blame to retailer, which also won't be very happy with such mess.

Even that @Yannis Rizos is right. The biggest challenge is making the sense of the data. However, so far no site have achieved 100% automation. You can use every fancy technique out there, but you will get somewhere between 80% to 90% correct mappings. Even when you use EAN/UPC or P/N as with any open standard, there are always some people misusing it. So at least to some extent you are going to rely on manual corrections.


答:
The key is:

clean and well organized code

good source control (probably distributed) supporting branching and automated merging

automated test suite

continuous integration which can grow to continuous delivery

You can either:

Create everything in trunk and revert all incomplete stories (after branching) from the trunk. This can have significant impact on the code base especially if stories required big changes to shared code.

Use branch for each new story and merge it only when the story is done. It has one significant problem. The story is tested in isolation and the feedback is collected to slowly but imho this is the easiest practice. Big helpers are good tools and good code / tests.

Develop all user stories in trunk and keep shippable product in branch. It solves to problem with isolation but it has high demands on merging strategy which can be very hard in case of changes to shared code.

Combination. Keep the shippable product in the trunk and stories development in branches. Merge all commits between branches and trunk (every branch must always have the latest committed code from others). Make sure that new features in trunk will be available to end user only after the whole story is completed.

In the last option you will ship incomplete stories but they will not be available to user - only their code will exist in your code base. The requirement is that all other users stories must be working.

I have also used much simpler (but not Scrum like solution). We didn't removed incomplete stories if they didn't break the completed stories. We just said on review meeting that we were not able to complete these stories and that they should not be used because they don't work. This option is possible only in case of internal releases where end user just validates completed stories and is not going to use the product for the real work immediately after the sprint.

Title: How do I create a potential shippable product (PSP) at the end of a sprint?

Body:
I'm running a team of 4 developers and 2 testers and trying to abide by the Scrum principle of creating a PSP with every sprint. That means I need to create a potential release with all the user stories that got to Done and store it on some publish server for the PO to do with as they please.

My problem is how to technically create the build when some stories are not at Done at the end of the sprint? The code is checked in, but didn't completely pass testing.

If I only check-in code that is Done, i.e. code complete-reviewed-tested, I run in to the possibility of diverging code bases and merges that may be disastrous. For instance Developers A and B work on different features that modify assembly X. Dev A finishes coding, pushes assembly X to test. The next day Dev B finishes coding and pushes assembly X to test. Feature A comes back with bugs, feature B is perfect. Oops, sprint is over. Now, how do I create a PSP with feature B but not A?


答:
As was stated previously Learn Assembly.

An assembly language is a low-level programming language for computers, microprocessors, microcontrollers, and other programmable devices. It implements a symbolic representation of the machine codes and other constants needed to program a given CPU architecture.

So Assembly is a symbolic representation of machine code.

You may now be asking "Ok, so how do I learn all of that?" I am so glad you asked:

Understand what it is. It is very low-level and will give you a very in-depth understanding of a computer. You might want to start with Wikipedia and then read this short passage.

Learn it! Best reads are probably The Art of Assembly Language and Assembly Language Step-by-Step: Programming with Linux

Get coding!

Title: Resources on learning to program in machine code?

Body:
I'm a student, fresh into programming and loving it, from Java to C++ and down to C. I moved backwards to the barebones and thought to go further down to Assembly.

But, to my surprise, a lot of people said it's not as fast as C and there is no use. They suggested learning either how to program a kernel or writing a C compiler. My dream is to learn to program in binary (machine code) or maybe program bare metal (program micro-controller physically) or write bios or boot loaders or something of that nature.

The only possible thing I heard after so much research is that a hex editor is the closest thing to machine language I could find in this age and era. Are there other things I'm unaware of? Are there any resources to learn to program in machine code? Preferably on a 8-bit micro-controller/microprocessor.

This question is similar to mine, but I'm interested in practical learning first and then understanding the theory.


问:
Graduate expectations versus reality
When choosing what we want to study, and do with our careers and lives, we all have some expectations of what it is going to be like. Now that I've been in the industry for almost a decade, I've been reflecting a bit on what I thought (back when I was studying Computer Science) programming working life was going to be like, and how it's actually turning out to be.

My two biggest shocks (or should I say, broken expectations) by far are the sheer amount of maintenance work involved in software, and the overall lack of professionalism:

Maintenance: At uni, we were all told that the majority of software work is maintenance of existing systems. So I knew to expect this in the abstract. But I never imagined exactly how overwhelming this would turn out to be. Perhaps it's something I mentally glazed over, and hoped I'd be building cool new stuff from scratch a lot more. But it really is the case that most jobs are overwhelmingly maintenance, bug fixing, and support oriented.

Lack of professionalism: At uni, I always had the impression that commercial software work is very process-oriented and stringently engineered. I had images of ISO processes, reams of technical documentation, every feature and bug being strictly documented, and a generally professional environment. It came as a huge shock to realise that most software companies operate no differently to a team of students working on a large semester-long project. And I've worked in both the small agile hack shop, and the medium sized corporate enterprise. While I wouldn't say that it's always been outright "unprofessional", it definitely feels like the software industry (on the whole) is far from the strong engineering discipline that I expected it to be.

Has anyone else had similar experiences to this? What are the ways in which your expectations of what our profession would be like were different to the reality?

答:
I didn't get a degree, but I picked up a bit at college and university libraries and labs.

Big Iron - The technologies they were teaching were primarily mainframes and minicomputers. The dean of one college told me I wouldn't be able to get a job because I didn't even know what a masterfile was. I had no intention of working on mainframes since I couldn't afford one, but I wasn't going to be so foolish as to not be slightly prepared. VAXen were cool, and I was looking forward to getting paid to code on my own Micro VAX in my cubicle. What a shame that market totally imploded. (As it turned out I had two positions working with mainframes…as a contractor for IBM.)

Software Engineering - On the heels of Structured Programming, SASD, and other design methodologies, you might have thought we were going to be real engineers. I did. But teachers were giving very little guidance on the design techniques I read in the library. Students were left to fend for themselves and micros made it too easy to flail in code until they get an answer they were happy with. I didn't realize how much worse it was in the job market.
Somehow I got to do quite a bit of new code, so it wasn't so boring. But I also took over a lot, and they were bad enough it was like a new project because I had to fix up a lot of code. It was a combination of researching existing functionality and creating new code (its replacement); writing tools to simplify the process and instituting better project management.

High-tech Career - It's one thing when schools have old buildings and equipment (the punch card equipment was replaced the semester before I started…in 1984), but when you're working in a poorly lit warehouse or for a boss who hangs up on customers calling the support line, you start to realize your job description isn't likely to include cooking popcorn with a 5-megawatt laser.

Title: Graduate expectations versus reality

ContentLicense: CC BY-SA 2.5


问:
Enum with FlagsAttribute or IEnumerable<Enum>/ISet<T>
Which is the currently-accepted best practice in terms of C# enum usage, a bitwise [Flags] Enum (compared using | and &) or an IEnumerable of enum values? I'm thinking both from a code-conciseness perspective and from a maintenance perspective.

The only downside to using the Flags approach that I can think of is the inability to enumerate the values without doing the reverse enumeration:

```<code>var possibleValues = Enum.GetValues(typeof(MyEnum)).Cast<MyEnum>();
var applicableValues = possibleValues.Where(x => (containerClass.EnumProperty & x) == x);
</code>```

Whereas obviously the IEnumerable is easier to query.

EDIT:

As svick rightly pointed out, the IEnumerable would be perhaps the wrong collection to use, an ISet might be a better example.

答:
You can create a method that encapsulates enumerating the flags. This way, using flags is almost as easy as an IEnumerable<T>.

One reason why I would prefer flags is what those two approaches mean. With flags, you have a set. With IEnumerable<T>, you have a sequence. That means you have another edge case you have to consider: What if the sequence contains some item more than once?


问:
Contracting out software development; deliver user stories or business requirements?
We are a small company that I am lead developer on, and we have been having on and off meetings with a potential stakeholder for a good opportunity.  This stakeholder is helping us directly in getting a proposal together to a group of other stakeholders for software that they have a strong need for.  Hopefully if we sell them on our proposal (consisting of very high level features and general deliverables) then they will sponsor the project and it will grow organically from there to users around the country who will see how useful it is.

Problem is that we as a development are terribly bogged down as it is with prior projects, maintenance of existing production systems, and badly needed features on the backlog.  As it stands, because this project could be highly lucrative and there are no serious competitors, management wants to act FAST and get the most basic functionality out as quickly as possible, no matter the cost.

This isn't realistic for us without growing our team but that takes too much time.  They are thinking about contracting the development work out, but want me to be a business analyst and also have architectural say in the project.  When they finish major feature development, they anticipate my team taking responsibility over maintenance so clearly architectural control is important as we want the deliverables to be maintainable.

I am okay with this role, but am unaccustomed to it.  In house we typically don't use formalized requirements documents, and instead gather requirements from user stories, use cases, workflows and customer agreements.  We are used to formulating user stories but I am afraid that doesn't make sense to deliver user stories to an outside contract company as they will likely have their own project managment who might want to do things their way.  I wouldn't want to impose our unfamiliar project managment process on them if they find it alien and it slows them down.

I am thinking that extremely detailed formalized business requirements are in order because we want to be sure that they have the necessary guidelines to create quality software, but I have no idea what kind of effort this will take from myself alone.  I am also unsure of when to start.  Nothing is official yet, but I have 90% of the information I feel I need from stakeholders.  I just don't want to end up with management informing me that the deal was signed, we have to deliver in 6 months and to get him all the requirements documents by the end of the week.

Feeling a little in over my head here, do I formulate user stories or business requirements?  Any other helpful suggestions?

答:
Rather than determining how you are going to present your requirements, first focus on finding someone to build the system, preferably within the cost and schedule that is acceptable to your organization. The process should start with the creation of a high level overview that outlines the goals of the project, background and motivations, high level requirements, specifies exactly what is in scope and out of scope, and the required deliverables. At the same time as this is happening, legal would also be involved to determine intellectual property ownership, NDAs, any kind of regulatory compliance needed by the subcontractor, and so on. Both documents would be made available to the potential contractors to provide the information needed to build a proposal that addresses schedule, budget, resources, and even some risks.

At this point, it becomes a negotiation. You might get a series of costs or schedules that are out of line for your expectations, at which point you might need to revisit what you are willing to invest or reduce the size and scope of the project. There might be other questions from potential contractors that need to be answered for them to provide information. There's a back-and-forth period here to iron out a few more of the details that are needed to carry out the project. If you've never been involved in a negotiation, I'd highly recommend the books Getting to Yes: Negotiating Agreement Without Giving In and Getting Past No: Negotiating in Difficult Situations.

Based on your criteria, once you have a selected a contractor, the level of involvement depends on what is negotiated. I've personally seen everything from the contractor being a black box that receives requirements and, on a regular basis, ships the requested artifacts and deliverables out the door to the contractor being a glass box with a customer that is always or routinely on site, actively involved in the development process. And there are lots of shades of gray in the middle, with different levels of involvement between the customer and contractor. Ultimately, that depends on the contract and the agreement between the customer (your organization) and the constractor.

Since you mentioned that your organization is going to receive the product and continue maintenance and development on it, I would spend extra time vetting potential contractors on their development process and quality assurance practices. I'd also try to maximize visibility into their process and product throughout the life of the contract so you can spot potential problems early and take corrective action. So you should work with the contracting company to outline your roles and responsibilities to the project as well as their responsibilities to your organization. However, like I said, it's a negotiation, so you might not get 100% of everything you want.

Another option would be to hire temporary, in-house contractors, assuming you have the resources for them to work. They would need some kind of lead (which I would assume would be you), computers, build servers, a meeting or collaboration environment, desk space, and so on. Your organization would also have to spend time interviewing candidates and finding people who will work well together and perhaps within your organization. However, it could also lead to full-time employees in the future.

Under this situation, you can dictate the development process and have great control over how things are done. But you also have the costs such as adding people and infrastructure to deal with. It might or might not be more cost-effective, but it might be something to consider, especially if your company might be looking to expand over the course of the project or at its conclusion - you have a few potential future employees working with you.


答:
I am afraid that doesn't make sense to deliver user stories to an
  outside contract company as they will likely have their own project
  managment who might want to do things their way

You are the client, and you will be paying them ... tell them what they will get. Also, I don't think it is particularly vital what format the requirements are delivered in, any decent developer should be able to work with either.

Personally, I'd think about getting a couple of individual contractors/freelancers in rather than a large consultancy. You may well end up hiring the very people that the consultancy would have hired, it will just be cheaper and you'll have a closer relationship to the developers.

Title: Contracting out software development; deliver user stories or business requirements?

Body:
We are a small company that I am lead developer on, and we have been having on and off meetings with a potential stakeholder for a good opportunity.  This stakeholder is helping us directly in getting a proposal together to a group of other stakeholders for software that they have a strong need for.  Hopefully if we sell them on our proposal (consisting of very high level features and general deliverables) then they will sponsor the project and it will grow organically from there to users around the country who will see how useful it is.

Problem is that we as a development are terribly bogged down as it is with prior projects, maintenance of existing production systems, and badly needed features on the backlog.  As it stands, because this project could be highly lucrative and there are no serious competitors, management wants to act FAST and get the most basic functionality out as quickly as possible, no matter the cost.

This isn't realistic for us without growing our team but that takes too much time.  They are thinking about contracting the development work out, but want me to be a business analyst and also have architectural say in the project.  When they finish major feature development, they anticipate my team taking responsibility over maintenance so clearly architectural control is important as we want the deliverables to be maintainable.

I am okay with this role, but am unaccustomed to it.  In house we typically don't use formalized requirements documents, and instead gather requirements from user stories, use cases, workflows and customer agreements.  We are used to formulating user stories but I am afraid that doesn't make sense to deliver user stories to an outside contract company as they will likely have their own project managment who might want to do things their way.  I wouldn't want to impose our unfamiliar project managment process on them if they find it alien and it slows them down.

I am thinking that extremely detailed formalized business requirements are in order because we want to be sure that they have the necessary guidelines to create quality software, but I have no idea what kind of effort this will take from myself alone.  I am also unsure of when to start.  Nothing is official yet, but I have 90% of the information I feel I need from stakeholders.  I just don't want to end up with management informing me that the deal was signed, we have to deliver in 6 months and to get him all the requirements documents by the end of the week.

Feeling a little in over my head here, do I formulate user stories or business requirements?  Any other helpful suggestions?


答:
If you want to understand how the machine works completely, why don't you go the lowest level possible and build your way up to where you are (e.g., C,C++)?

By that I mean: why don't you build your own 4-bit adder with transistors on a circuit (just Google it if you are looking for instructions/tutorial)?

After that build a small computer with some RAM, and then start learning Assembly and write a program or two with it.


答:
The root issue here is stories not done at the end of the sprint. That is the problem you should try to solve.

In other words, ask the team "how can we finish all my stories by the end of the sprint?" not "how can we adapt our process to manage my half-completed stories".


答: My only attempt to use an IDE on Linux happened in 2005, but at that time no IDE I tried (KDevelop, eclipse, Anjuta) was any good, so I went back to vim+ctags+gdb and still using it for Linux coding.</p>

Title: Comparison of IDEs for C++ and C development on Linux: KDevelop, Eclipse, NetBeans, CodeBlocks and Anjuta

Body:
I'd like to note your experience of full scale IDEs on Linux.

I personally work mostly with vim, however other programmers would like
to see a real IDE. So I'd like to hear your personal opinion about different
IDEs and comparison between them, in following context:

C++ and maybe some C development (not Java, Python and other stuff)

Server side programming (no need for GUI development)

Working on Linux not "cross-platform" development.

Opinion needed regard:

How stable is it? If IDE crashes I don't need it.

Comfortable to use.

Powerful for debugging.

Integration with various build systems

Scalability over huge projects (projects of hundreds thousands of lines of code)

I used to work with KDevelop and it was very nice IDE and seems that KDevelop 4 is a huge progress. It seems also that many rather use Netbeans and Eclipse.


问:
Storing documents in Database vs CMS in JSF, Seam, Hibernate application on cloud
I am about to start with an application using JSF 2, Seam 3, Hibernate and Hibernate search with the following characteristics:

Users will be uploading documents (pdf, doc).

There can be millions of documents.

The application will be deployed in the cloud.

Here are my questions:

What will be the best place to store the documents: a database or a content management system (CMS)?

If choosing a database, should I go with document oriented db?

Is there any integration between Hibernate and document oriented databases or CMS to fetch the documents and index it in Lucene?

Basically I am looking for an approach that will be good for storing documents in the cloud, easy accessibility of documents for indexing and keeping performance in mind.

Any suggestions / experience or link on this will be good.

答:
You are confusing a few concepts here.

Basically CMS is an Application that USES a Data store. The CMS its self will store file in either the File system or in a DB. These are not mutually exclusive. A CMS may use document oriented database but I don’t know of any that does.

Your best bet (if not using an off the shelf CMS) is to use a standard DB, Store all your file attributes in the DB but the store the actual files in the file system. Store the file location in the DB. (Web servers are better then DBs at serving up files.  So this configuration will give you the best of both worlds.)  Millions of docs should not be a problem.

I don’t know enough about Lucerne or document oriented databases to comment on it. -Sorry.


问:
What should we include in SSAS cube design documentation?
What should we include in a SSAS cube design documentation?

This is the initial phase of the document. I have included:

data models,

facts,

dimensions,

surrogate keys,

hierarchies and levels within hierarchies,

reports that we can pull from the cube,

proactive caching.

What else can we include?

答:
How About the a source of the data and descriptions of all the ETL\ business rules needed to load the Cube?

It's a common misconception that to build data Cube all you need to do is learn how to model the Star Schema. But the Truth is getting all data from multiple sources, cleansed and married together in a unified format is much harder then building the cube. It mat be a good idea to document some of that stuff.

Also throw in Data Dictionary, those are always nice to have with a complex BI system.


问:
What are C's advantages over OOP languages, other than performance?

Possible Duplicate:

  When to use C over C++, and C++ over C?

C still has its own importance in the programming world! And one reason for it is its performance. But, I have some questions.

Is there anything that is special to C that other languages missing?

What are its importance today, other than performance issues?

What are the advantages of C over OOP languages like C++, Java, Python, etc.,?

Is there anything other that gives a plus point to C?

答:
I can name two: simplicity and portability.

C is much simpler than C++, which is the closest thing to C among the OO languages.  Just compare the K&R book to Stroustrup's "The C++ Programming Language".  Don't get me wrong, I love C++.  But it is a very complicated language, with an enormous number of language features, which take a long time to master.  C, by comparison, is very simple with only a few constructs.  And I am not talking about libraries here, just the bare language features themselves.  The same is true if you compare C with Java, C#, or any other OO language.  IMHO, the only language simpler than C is Scheme, a functional language.

The second reason is that there is a C compiler for everything.  Every processor and every operating system.  And I am not just talking about Windows vs. Linux.  There are hundreds of embedded platforms, processors, and DSPs.  You would be extremely lucky to have a C++ compiler for one of those, let alone a JVM.  But you would definitely expect to have a C compiler.


问:
Static methods on a web context
What happens when concurrent requests call the same static Java method running on an application server?

Say that a method run takes 2 seconds and receives 100 calls in a given second. The method itself wouldn't read/write outer state.

Could it be better to let it be an instance method instead?

答:
static as far I can explain means that whatever is declared with static will exist in a single place in memory as a single instance for everyone, kind of a shared variable or function.

so generally is not a good idea to declare a static variable that is not constant unless you need something like a global counter.

However you may have a static function that does not change any values and only accepts values a returns other values, in that case I see no problem there.

However how Martijn explained is always better to test your code understress. I for example don't know what to expect of static functions that call objects

Title: Static methods on a web context


答:
The best and most reliable way is to use a feed provided by the merchants. Usually this will be in the form of an RSS feed or a web service. Some merchants only offer these feeds to registered affiliates and they won't be easily discoverable by the general public. Plus, as an affiliate, you should get paid for customers you send to the merchant from your site. The downside, of course, is that Google actively tries to penalize sites like you've described since they consider them "web spam" (aka advertising competitors).

As long as you're using merchants feeds/services the data acquisition is trivial. The real challenge is in formatting and presenting the data in an engaging format, along with other content, that will retain visitors and get them to directly return to your site even if Google sends you to the back of the bus.

Title: How to : Nextag and such other dynamic data pulling website

Body:
Yesterday, I came across Nextag which is a website for comparing prices of various products from different retailers. Is this site automated?

Can the process of data pulling from various sites can be automated for comparison with each other. I tried understanding a hell lot, but could not realize this fact and now think that they ought to be manually managed because on every other retailer site, the product name was different and it was very hard to recognize a similarity for a specific product.

I have made such a system in which one can add a product and then add the respective retailers and their pricess. Every thing is manual in here. Today, I will be entering the data into the system, but thought it would be better to know if there is a way to automate this thing. Or I am going the right way as there can't be an automation for such system, because the data has no similarities.


问:
Transitioning from being a bespoke development to a COTS development house
Currently one of the major applications that our organisation produces would be regarded as bespoke software as it is specifically designed for one specific client organisation.

However, we have specifically retained the intellectual capital on the project and a number of different organisations in different countries (with different languages and character sets) now look like they want to purchase our software solution.  Our current approach to development passes 9 ½ out of the Joel Test and is improving.  However, our approach is all about satisfying the requirements of one specific client and responding quickly to their needs (regardless of whether something is a bug or a change request).

If we want to transition to producing more of an 'Off the Shelf' approach with multiple client organisations---rather than just one client organisation---on a common code base, what are the major differences and what pitfalls do we need to be aware of to successfully make the transition?

答:
Since you'll have multiple clients, your build/test/deploy process will need to be more robust. If you already have strong engineering practices, then this should be doable, though it still will be a transition. But that's the easy part...

With only one client now, the customer-facing part of your business is straightforward. However with many clients, you'll need to be able to handle all of them independently. You'll need a help desk, possibly a public issue tracker, etc. (There is a reason big companies have "support" engineers on staff; this is a full-time job.)

On the business side, you'll need to ramp-up your sales and marketing. You'll need to cultivate new sales leads and track the satisfaction of existing customers. So if you want to grow big enough, this may mean using CRM or other automated solutions. You'll also have to "get the word out" about your product, which can happen through PR, advertising, tech conferences, etc.

So your process for building the product will need to become more "professional", yes. But it's selling the product that will be the hard part. Good luck!


答:
Some signficant organizational and architectural changes should be enacted to be successful at developing a common product that meets all of your clients specific needs.

Organizationally you will need to change from directly delivering requests of clients to a situation where the development team delivers requests to a product owner within the company.  Once you do this, the development team is not working for the clients of the company anymore, the only client that should matter to the development team is the product owner in YOUR company.

The product owner will have to gather requirements from the mutliple clients and determine a common set of requirements that will make the majority of them happy.  The development team only needs to worry about making the product owner happy.

Architecturally it helps when designing a product that has a wide array of customer needs to make it as configurable, extensible, decoupled, scalable and componentized as logically possible.

Some good approaches to doing this would be to take the many different pools of requirements and find out what pieces are common amongst all of them.  These common requirements will constitute the core of your featureset.  Everything that is slightly different than the core can be determined as a configurable feature, setting, or perhaps a whole unique feature that is seperate from the core.  Make these seperate features as componentized as possible and spec it out well.

Your customers may look at different features that are currently disabled for their installation of a product and may realize that they might actually want that feature too.

Finally, try to be a "Defensive Designer" without violating the YAGNI principle.  This can be a fine line to traverse, but it is a very real possibility that certain architectural and design assumptions can cause you to develop yourself into a corner, causing the need for major refactoring in a future release.  Assumptions are CRITICALLY important and should be closely detailed and scrutinized in your technical specifications.  An incorrect assumption can cost you dearly later.  A good way would be, "I know that the customers are pretty certain that they would like this component to work this specific way, but just in case, I am leaving the option open that this COULD change in the future without causing the need for a major revamp."  Sometimes this is as simple as proper componentization and decoupling, other times it borders on possibly developing features that were not requested.  You have to make that judgement call for your situation.

Title: Transitioning from being a bespoke development to a COTS development house

Body:
Currently one of the major applications that our organisation produces would be regarded as bespoke software as it is specifically designed for one specific client organisation.

However, we have specifically retained the intellectual capital on the project and a number of different organisations in different countries (with different languages and character sets) now look like they want to purchase our software solution.  Our current approach to development passes 9 ½ out of the Joel Test and is improving.  However, our approach is all about satisfying the requirements of one specific client and responding quickly to their needs (regardless of whether something is a bug or a change request).

If we want to transition to producing more of an 'Off the Shelf' approach with multiple client organisations---rather than just one client organisation---on a common code base, what are the major differences and what pitfalls do we need to be aware of to successfully make the transition?


问:
Methods on packaging an assembler with compiler
I am planning on creating a compiler that will generate assembly, that is as far as I really want to go with this project (don't want to create the object files myself or any of the machine code). Since I'm doing this on linux, I would like to use the gas assembler. I'm not sure the best way to package the application. Should I require that the people have gas on their system already (which it is on most linux distros by default if I'm not mistaken, which I could be)? Or is it better to package the source with my application, or even package the actual application with my compiler?

By packaging I mean any form of distribution so that would include putting the code up on github as well.

答:
I won't bother about packaging your hypothetical compiler first. Work on your compiler prototype, and publish its source code in a free license (because nobody will pay you for your compiler!!!). If it interests some people, it will become packaged, or at least you'll get (later) suggestions on how to do so.

You could look at existing compilers packaging (e.g. for GCC, tinycc, Ocaml) in common linux distributions.


问:
What is a practical way to debug Rails?
I get the impression that in practice, debuggers are rarely used for Rails applications. (Likewise for other Ruby apps, as well as Python.)

We can compare this to the usual practice for  Java or VisualStudio programmers--they use an interactive debugger in a graphical IDE.

How do people debug Rails applications in practice? I am aware of the variety of debuggers, so no need to mention those, but do serious Rails programmers work without them? If so, why do you choose to do it this way?

It seems to me that console printing has its limits when debugging complex logic.

答:
If a rails app is well written, with fat models covered by tests and slim controllers and views, there's no need for debugger, because most bugs happen in models and can be detected by tests and console.

However, I maintain a couple of legacy rails apps where I use debugger often (ruby-debug gem), because both controllers and views have a lot of action in them and in such case, debugger is the only way to check out specific app state.

Title: What is a practical way to debug Rails?


答: Concurrent requests should be handled by your web server. There should be no difference between accessing a static function versus an instanced function so long as no state is modified externally. Each request will simply call and execute the function regardless of whether another existing call is running. I believe the only concern should be whether your server can handle the load of calling that function 100 times inside of a second.</p>

Title: Static methods on a web context

Body:
What happens when concurrent requests call the same static Java method running on an application server?

Say that a method run takes 2 seconds and receives 100 calls in a given second. The method itself wouldn't read/write outer state.

Could it be better to let it be an instance method instead?


问:
Why was I asked general, non-technical questions during an interview?
I got through the first phone interview at Amazon last week and they asked some basic technical questions during that interview.

Today, I had my second phone-interview and I prepared myself well expecting for another technical interview, but it was not technical at all.

After we introduced ourselves, he asked questions like:

Why do you like to do programming?

What do you Not like about programming?

What do you expect from a new job?

In the last project you worked on, how did you make sure the project was implemented to the client's requirements?

Was there was any project, that during the development, you felt like the design was bad, and if so, what did you do to fix the issue?

As an engineer how would you keep up with the new technologies?

Additionally, when I explained to him about a recent project I worked on, he asked me about why we decided to make a specific design decision and whether it was my decision.

I was wondering why he asked me these kind of questions; since English is not my native language, I assume that one of the reasons was to test my knowledge of the language.

And most of the answers I gave him were very short and since I felt like he's expecting more, I tried to come up with things to say and ended up just blabbering. Overall I think the interview went really bad because I couldn't clearly convey my points to him.

Why was I asked these types of questions, and what kind of answers do interviewers expect?

答:
Regarding why they asked these kinds of questions, I ask these sorts of questions in every interview I do. When hiring someone, I want to know how they handle different situations, their thought process when trying to solve problems, how the handle stressful/negative situations, etc.

Someone knowing a certain programming language is only a small part of the hiring decision. Knowing the prospective employee will make smart decisions, take responsibility for their actions, etc is more important.

As far as what answers are expected... Honest ones. I appreciate when someone will respond with details, and are willing to admit their role (both positive and negative) in various situations. Additionally, questions like "What do you like about programming" to me help reveal more about a candidates personality than anything specifically about programming.


答:
It is open-ended questions. They are tailored to see how easily you can describe your views on your practice. The main objective of those questions is to make you talk, not to test your English skill (even if communication skills can be tested this way), but to see if you are passionate (Why do you like to do programming? Details about your latest project?) about what you are doing, and if you feel invested in your practice.

They are also asked to see if you can take a distance, and judge yourself in your practice, that you know your weak points.(What do you not like about programming?)

There are also some questions that can be considered as BS-detecting questions(Details about your latest project?). That's because the last thing someone wants in a team, is someone lying, so you have to get in the details of what you are pretending you've done.

Then, there are also the questions about your evolution as a competent programmer(How do you keep up with the new technologies?), and your capacity to constantly evolve without being constantly asked to.

Overall, those questions are generally asked to make a connection, and see if you are a good fit for the company and it's culture. It's totally subjective. The goal is to see if communication is easy, and ideas can be easily shared. If you feel that you did bad because that connection didn't happen, well maybe it's better that you pass to the next company.

Title: Why was I asked general, non-technical questions during an interview?

Body:
I got through the first phone interview at Amazon last week and they asked some basic technical questions during that interview.

Today, I had my second phone-interview and I prepared myself well expecting for another technical interview, but it was not technical at all.

After we introduced ourselves, he asked questions like:

Why do you like to do programming?

What do you Not like about programming?

What do you expect from a new job?

In the last project you worked on, how did you make sure the project was implemented to the client's requirements?

Was there was any project, that during the development, you felt like the design was bad, and if so, what did you do to fix the issue?

As an engineer how would you keep up with the new technologies?

Additionally, when I explained to him about a recent project I worked on, he asked me about why we decided to make a specific design decision and whether it was my decision.

I was wondering why he asked me these kind of questions; since English is not my native language, I assume that one of the reasons was to test my knowledge of the language.

And most of the answers I gave him were very short and since I felt like he's expecting more, I tried to come up with things to say and ended up just blabbering. Overall I think the interview went really bad because I couldn't clearly convey my points to him.

Why was I asked these types of questions, and what kind of answers do interviewers expect?


答:
They weren't asking you the questions because you aren't a native English speaker. Questions like this are typical in an interview. The technical questions are asked to learn about your skills and what technical background you can bring to the team or the company. However, companies also want to hire people who are a good fit for the culture and who can contribute in other ways, perhaps outside of their primary role or who can grow into new positions within the organization.

The questions about what you like and don't like about programming might be indicative of your work ethic and your capabilities to learn and adapt to your development duties in the future. They want to see how passionate you are about the work that you are going to be doing and make sure that you aren't going to be someone who comes in, does their time, and leaves without enjoying the work that they are doing. It's well known in organizational behavior that employees that are happy in carrying out their responsibilities are more productive and tend to contribute to the team's performance.

Asking what you expect from the job gives the interviewer some insight into why you want the position. They want to know if you are looking for a 40-50 hour/week job for the paycheck, or if you are passionate about your field. They want to know what you are looking for from your company, in terms of personal and professional development and growth. Again, it goes back to a cultural fit with the team and the organization. Companies aren't just looking for people to fill a desk, but rather contribute to the knowledge and capabilities of the organization. In order to do this, they need to know what you are expecting to be a happy, productive, contributing worker.

Questions about past projects are designed to learn about your decision making, leadership, and personal interactions. This is partially technical and address concerns about your ability to make sound technical decisions, or to learn from your mistakes. They also identify you capabilities to work with other people, to recognize your own shortcomings, and to learn from mistakes.

All of these questions also cover your ability to communicate about yourself and your desires and goals with other people. Software engineering is just as much about communication as it is designing and building software systems, so being able to think and explain yourself clearly to the interviewer is important for these subjective, open-ended questions.

From an interviewer's perspective, you should be providing answers that are honest and complete. Don't go into every little detail - the interviewer will ask for more if they want it. However, discuss enough to give them an idea about how you think, act, and respond to various situations. That's what they want to know about.


答:
These are soft questions that do not have a right or wrong answer, but are intended to determine the way you think, what kind of personality you have, and whether your personality will fit with their culture.  This is something that non-native english speakers as well as people who come from a different culture can have a hard time with, especially Asian cultures.

The biggest hangup I see when asking these kinds of questions to people of Asian cultures is that they have a huge problem with admitting personal fault in an introspective way and positive way.  Many westerners see the ability to admit ones faults and suggest how to improve themselves as an admirable quality (this may be influenced by Christianity and religous need to admit ones faults to God?).  Most people of Asian cultures I have worked with view this kind of introspective admission as an extraordinary sign of weakness and I can respect that viewpoint too.  Not all westerners understand this.

Another hangup I see is the inability to say No to a superior.  This is another cultural difference between highly regarded western values like how we view being independently minded and creative as more important than being subservient, placating or respectful.

These cultural barriers can be bridged by each side respecting and having a greater understanding of differing viewpoints and the strengths and weaknesses of each others culturally instilled values.

EDIT: My answer seems to have stirred some controversy so I will clarify some points.  These are not based on any scientific evidence or studies that I know of.  My answer is completely my opinion based on Asian studies, philosophy and world history courses that I had taken in University, as well as several close friendships with people from many cultures across the world.

Further I would like to clarify that I am not discussing racial differences, merely cultural differences.  My opinions are that the more we are aware of each others background, the less we subconsciously judge those that are different from us.  I in no way am saying that one culture is superior to another.  If you believe that acknowledging cultural differences is in fact discrimination then I understand and respect your opinion, however I humbly disagree.


问:
Example of an Object Oriented System design
In the early days of web programming there was the Java Pet Shop application which was used as a reference type of example application.

Currently I am looking for a similar reference but with the emphasis on systems =design=. I.e. what aspects of his / her design should an architect / systems-designer put on paper and communicate thoroughly with developers and client ( management ).

I am looking for an actual and complete example or reference, not a list of properties of good design, etc. ( Possibly of a hypothetical system. )

答:
Craig Larman's Applying UML and Patterns covers an extended case study designing a "point of sale" system for retailers. It goes from requirements analysis, through object-oriented design, to implementation and testing. There are lots of diagrams (UML, obviously) at incremental points in the design stage illustrating how to communicate system design in various ways.

This was the case study I followed in college learning software design. It's the most thorough example I've seen anywhere.


答:
I feel you man.  I just graduated little over a year ago in fact, jumped on the first job offer that came my way and got the biggest shock of my life.

Things I didn't expect:

School stress and Work stress aren't the same
- The stress of working on a school project with friends, or working solo, even with that looming thesis deadline or special project defense does not compare to the stress of seemingly unreasonable work deadlines, communication problems, (a little of office politics) and crunch times.

Lack of Best Practices
- Same as your experience on professionalism. Before taking my first job and during my training period, I rushed off reviewing and reading about best practices in both programming and software engineering.  These aren't followed as well as they should for impractical and, to be fair, practical reasons. And sometimes, your knowledge counts very little against others who are merely afraid of the unknown and treat these practices with disdain.

What they taught in school was just the tip of the iceberg
- Thinking that what I learned self-studying and from classes was enough to get me through, I was shocked to say the least as I stared dumbfounded at the first piece of code I was supposed to maintain.  A lot of the skills I use now were learned on the job or during my job that I keep on wondering if I could've made it without a college degree at all. XD

The Importance of Communication
- Made me realize what all those English classes were for. Before the real world, I could not see the relevance of having three to four different English classes in college when it's been taught since we were in the first grade. You're no use in your job when you can talk to a computer but fail to talk to people.

Title: Graduate expectations versus reality

Body:
When choosing what we want to study, and do with our careers and lives, we all have some expectations of what it is going to be like. Now that I've been in the industry for almost a decade, I've been reflecting a bit on what I thought (back when I was studying Computer Science) programming working life was going to be like, and how it's actually turning out to be.

My two biggest shocks (or should I say, broken expectations) by far are the sheer amount of maintenance work involved in software, and the overall lack of professionalism:

Maintenance: At uni, we were all told that the majority of software work is maintenance of existing systems. So I knew to expect this in the abstract. But I never imagined exactly how overwhelming this would turn out to be. Perhaps it's something I mentally glazed over, and hoped I'd be building cool new stuff from scratch a lot more. But it really is the case that most jobs are overwhelmingly maintenance, bug fixing, and support oriented.

Lack of professionalism: At uni, I always had the impression that commercial software work is very process-oriented and stringently engineered. I had images of ISO processes, reams of technical documentation, every feature and bug being strictly documented, and a generally professional environment. It came as a huge shock to realise that most software companies operate no differently to a team of students working on a large semester-long project. And I've worked in both the small agile hack shop, and the medium sized corporate enterprise. While I wouldn't say that it's always been outright "unprofessional", it definitely feels like the software industry (on the whole) is far from the strong engineering discipline that I expected it to be.

Has anyone else had similar experiences to this? What are the ways in which your expectations of what our profession would be like were different to the reality?


答:
You can reverse engineer a similar project to yours. I mean you usually you get jar files but it is possible to reverse them into a single UML model and then generate the skeleton of this application into java.

There is no copyright on project architecture but only on the code therefore you have the right to copy the skeleton of an existing software as long as you don't copy the code.

Title: Example of an Object Oriented System design

Body:
In the early days of web programming there was the Java Pet Shop application which was used as a reference type of example application.

Currently I am looking for a similar reference but with the emphasis on systems =design=. I.e. what aspects of his / her design should an architect / systems-designer put on paper and communicate thoroughly with developers and client ( management ).

I am looking for an actual and complete example or reference, not a list of properties of good design, etc. ( Possibly of a hypothetical system. )


答:
One of the biggest issues you have to deal with is customization. Since you may no longer be responding to individual requests but rather making changes to a product that serves many, you need to decide how to handle the need for some of your clients (especially your intial client who is used to requesting custom solutions) for custom information.

You will also need to learn to filter requests for changes based on what the product needs vice what one company needs.

There are several routes to take in regard to customization and you need to decide which one:

Allow no customization - will lose some customers maybe even your
bread and butter first customer

Create an EAV table in the relational database to allow for lots of
customization -flexible but slow and hard to query

Create a few undefined columns in key tables to allow for limited
customization - can work if you have already designed the 95% that is
really needed

Use a no sql database for customized information - fine for things
that don't need transactional integrity

Create separate instances per customer and charge an arm and a leg
for customization (especially for custom reporting) - can be very
expensive and hard to manage

Treat all customization requests as something that all customers will
get or be offered as an add on (modularly develop the customization
so people can pick and choose what features they want) - may be able
to handle most development this way depending on how your current
software is structured and what it does.

You need to really think through these issues as customization done wrong can make your software unbelievably slow or can result in the need to for many more programmers than no customization. You may also consider using several of these techniques. All have pluses and minuses.


问:
Strategy to use version control on a modular system
Let's suppose (for simplicity) that we have an application featuring client and server; is there a better idea to use one repository for both or a pair of separate repositories?

Mixing them will probably make easier to track correlated changes and maintain correlated branches (i.e. protocol evolution), but on the other hand will make the individual development more cluttered...

答:
If you are using git or mercurial, then you might want to look at submodules or subrepositories.

The client, server and their interface files would be in their own repositories, but would be tied together at the super-repository level. This would allow you to do one checkout at the top level and git or hg would check out the appropriate commit of each of the submodules/subrepositories.

By only committing to the super-repository when both client and server were appropriate to each other, the super-repository would only ever give you the option to check out a working system - so you would never try to run the new client against an old server or vice-versa.

Submodules/subrepositories give you all of the advantages of using separate repositories, along with the advantages of a single monolithic repository, at the expense of a little extra complexity.

This answer is not intended to advocate git or hg over other SCMs, it just happens to be that I only know these SCMs well enough to know that this option exists. I don't understand how svn externals work for instance.


答:
Separate!

In fact, I'd probably have three repositories, one for the Client and corresponding client-only libraries, one for the Server (and corresponding libraries), and one for the shared libraries (incorporating the API interfaces that expose the functionality between the two, plus any other shared code). I think that's really the key, the shared code should go into a separate repository of its own. That way you can make sure that the interoperability between your client and server is both always at the same version AND is isolated from the design of each of its consumers.

Obviously, this is not always possible, depending on the particular communication framework you're using, but there's likely to be shared code that dictates the format of the data-transfer objects or the handshake steps in your custom protocol (or some other example).

Assuming you have a fairly decent Continuous Integration and QA setup (a fairly large assumption, in my experience, but one I'm going to make nonetheless. If you don't have a QA department you should at least get some CI) you shouldn't need to use the single-repo pattern as a defense against possible code mis-matches, either your CI server will flag up library-interoperability or your QA team will catch runtime errors (or, even better, your Unit Tests will).

The benefits of split repositories lie in the ability to separately version separate parts of a system. Want to take a copy of last week's Server and run it with this week's Client, to try and lock down the root of a performance issue? No worries.

Title: Strategy to use version control on a modular system

Body:
Let's suppose (for simplicity) that we have an application featuring client and server; is there a better idea to use one repository for both or a pair of separate repositories?

Mixing them will probably make easier to track correlated changes and maintain correlated branches (i.e. protocol evolution), but on the other hand will make the individual development more cluttered...


答:
Require that people have gas. This is the preferred way for most OSS software, and you make life for potential distributors a lot easier by sticking to the standard.

The rationale behind the standard is a variation of DRY: If everyone would be packaging dependencies with their source packages, any distribution would face a myriad of similar libraries with different versions in the different source packages.

There are three places where you should indicate dependencies:

In the human-readable README file of your project

Checked at source configuration time by autoconf via configure and configure.ac

Checked by the package manager for binary distributions by setting a Depends directive (.deb) or a dependency (.rpm)

Title: Methods on packaging an assembler with compiler

Body:
I am planning on creating a compiler that will generate assembly, that is as far as I really want to go with this project (don't want to create the object files myself or any of the machine code). Since I'm doing this on linux, I would like to use the gas assembler. I'm not sure the best way to package the application. Should I require that the people have gas on their system already (which it is on most linux distros by default if I'm not mistaken, which I could be)? Or is it better to package the source with my application, or even package the actual application with my compiler?

By packaging I mean any form of distribution so that would include putting the code up on github as well.


问:
How do delegates fit into ASP.NET?
A developer told me they used delegates to bind most of their events in ASP.NET.  Until then, I did not even know it was possible to use delegates in ASP.NET in a meaningful way.

My understanding is that ASP.NET/MVC3 works via HTTP verbs, not events/delegates.  Is it even possible to have an event fire from the client to the server?  This strikes me as an invalid form of IPC.

答:
It does work through HTTP verbs, but the event model in ASP.NET is correct too.

ASP.NET tries to abstract the underlying complexities of HTTP stateless communication in a way that would be easy for traditional WinForms and VB developers to understand.  It is debatable if they actually acheived this goal however.

For more information see the MSDN article on the ASP.NET Life Cycle

ASP.NET bridges the gap by having what is known as a ViewState exist on both the server side session and a client DOM element.  Everytime there is a postback to the server, the ASP.NET lifecycle events are fired in order, causing the server side objects to be created, updating the viewstate with the updated information from the client, updating the server side elements with data from the viewstate, executing any server side events that need to be executed, and finally rendering the HTTP response to return back to the client.

The client at that point will take the updated viewstate from the server and use it to update its own DOM elements and execute client side events as necessary.

If it seems complex that is because it is.  This is why many view it as a failure because it requires detailed understanding of the underlying architecture to really become good with it.

Title: How do delegates fit into ASP.NET?


答:
Delegates are used in ASP.NET for binding the events from controls on the page to the functions in your code behind. If we take the ASP.NET button for example, we have the click action, command action, DataBinding action, along with Disposed, INit, Load, PreRender and Unload. All of those have delegates associated with them and if you create a function that does something with it, the delegate will point to your function.

I think the confusion is when you use the delegates. Since ASP.NET MVC3 is built on ASP.NET and is not its own beast. You will still use delegates when using input fields or any of the asp controls even when using MVC. Like maple_shaft says:

Everytime there is a postback to the server, the ASP.NET lifecycle events are fired in order, causing the server side objects to be created, updating the viewstate with the updated information from the client, updating the server side elements with data from the viewstate, executing any server side events that need to be executed, and finally rendering the HTTP response to return back to the client.

The way that the events are executed is through the use of delegates.

Title: How do delegates fit into ASP.NET?

Body:
A developer told me they used delegates to bind most of their events in ASP.NET.  Until then, I did not even know it was possible to use delegates in ASP.NET in a meaningful way.

My understanding is that ASP.NET/MVC3 works via HTTP verbs, not events/delegates.  Is it even possible to have an event fire from the client to the server?  This strikes me as an invalid form of IPC.


问:
Insert grammatical mistakes in a correct sentence
I'd like to insert grammatical mistakes (not typo) in a correct sentence, to make a small game. For instance:

```<code>My name is John
-> My name are John
He leaves the room
-> He leave the room
</code>```

I only found some tools to detect languages but nothing about verb/noun/adjective detection/transformation. Is there a tool that could help me ?

答: I do not know of any tool, but on "Kevin's Word List Page" on SourceForge you will find some wordlists with part-of-speech (POS) information: http://wordlist.sourceforge.net/ (That's what you refer to as "verb/noun/adjective".) I hope it will be helpful to you.</p>


答:
In your example, those aren't spelling errors, those are grammatical errors. Creating random spelling errors is fairly straight forward, creating grammatical errors is quite a bit more challenging.

I'd recommend finding a word list with part of speech information, that includes all case-number-gender declensions (he, him, his, etc). Then, when you find a word that has multiple declensions, switch it with one of the others randomly.

If you want to be particular about swapping only verbs, or only nouns, you're pretty much not going to do it reliably, because writing a computer program to reliably tell when a word is being used as a verb, noun, or adjective is a significant challenge in and of itself.

Title: Insert grammatical mistakes in a correct sentence

Body:
I'd like to insert grammatical mistakes (not typo) in a correct sentence, to make a small game. For instance:

```<code>My name is John
-> My name are John
He leaves the room
-> He leave the room
</code>```

I only found some tools to detect languages but nothing about verb/noun/adjective detection/transformation. Is there a tool that could help me ?


答:
Looks like the Lancaster (Paice/Husk) stemming algorithm (or an alternative) might get you one method to insert random grammatical errors.

Wikipedia:

In linguistic morphology and information retrieval, stemming is the process for reducing inflected (or sometimes derived) words to their stem, base or root form—generally a written word form.

So, this algorithm will give you the ability to take words such as "taken" or "waiting" and derive their root forms ("take" and "wait"). I don't believe, however, that it produces the derived forms from roots.


答:
If you look at software today, through the lens of the history of engineering, it’s certainly engineering of a sort—but it’s the kind of engineering that people without the concept of the arch did. Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves. -Alan Kay, 2004

the full interview: http://queue.acm.org/detail.cfm?id=1039523

I'm no industry vet; Quite the opposite, I'm a recent graduate but from a top CS school in the U.S. But my instinctual feeling is that the way we are building software is wrong. Rather than hitting the pause button and reexamining the fundamentals of how we program we have just rushed forward using out dated models from the 50s,60s continually adding a little sugar on top. If we keep on like this we will never get past where we are at. Humans just can't manage the complexity of things that are the size of the MS Windows codebase. We need a new way. I don't know what that is.

I think this is the underlying reason for the feeling that big and small software shops seem to make software by hacking it together without any deep understanding of fundamental principles.

Title: Graduate expectations versus reality


答:
In Mercurial, this scheme can be used, using -> to denote subrepo relationship:

```<code>product -> client -|-> (many components)
                   |->  shared component A

        -> server -|-> (many components)
                   |->  shared component A
</code>```

Product has subrepos client, server. Each of those has their components as subrepos, possibly at least one subrepo shared between the two.

Tagging should probably be done on the first two levels, not below that.

Commits are done on the component level, the superrepos effectively track named branches and versions of the product. Named branches/bookmarks are usually better than clone branches for usability (ie trainability) and compatibility with subrepos.

hg tends towards the assumption that superrepos are the product, and commits are done at the top level, but that doesn't work particularly well when multiple products use the same components. :-)

I don't think that this scheme will change much if transitioned to git, but I haven't tried it out in git yet.

Body:
In Mercurial, this scheme can be used, using -> to denote subrepo relationship:

product -> client -|-> (many components)
                   |->  shared component A

        -> server -|-> (many components)
                   |->  shared component A

Product has subrepos client, server. Each of those has their components as subrepos, possibly at least one subrepo shared between the two.

Tagging should probably be done on the first two levels, not below that.

Commits are done on the component level, the superrepos effectively track named branches and versions of the product. Named branches/bookmarks are usually better than clone branches for usability (ie trainability) and compatibility with subrepos.

hg tends towards the assumption that superrepos are the product, and commits are done at the top level, but that doesn't work particularly well when multiple products use the same components. :-)

I don't think that this scheme will change much if transitioned to git, but I haven't tried it out in git yet.


答:
Forget about the repository for a moment. How would you organize the two projects on your machine if you weren't sharing with anyone? How would the rest of the team do it? Would you...

Put all the source files for both client and server in the same directory?

Create a main project directory that contains subdirectories for the client and the server?

Keep the two projects completely separate?

Once you come to some consensus about that as a team, you're ready to check the projects into your code repository. All the revision control tools that I can think of are happy to reproduce any directory structure you like -- they don't care one bit about which file belongs to which project. And the difference between having one repository or two (or six) is usually not that great, aside from minor administrative differences.

For example, with Subversion, the biggest difference between separate repositories for client and server and a single combined repository is in the way the revision numbers change. With a singe repository, the version number will increase each time you commit code to either client or server. With separate repositories, a commit to the server project won't change the head revision number for the client.


问:
Why disallow int-to-short assignment but allow multiplication and other math?
In Java, the following code does not compile:

```<code>int val = 1;
short shortVal = val;  // Incompatible types
</code>```

Anyone know why Java chooses to complain about this assignment, instead of simply truncating, when an integer × integer is also likely to overflow?

To illustrate:

```<code>int val = 46340;
int result = val * val;                    // 2147395600
System.out.println(result);
int overflowVal = 46341;
int result2 = overflowVal * overflowVal;   // -2147479015
System.out.println("Quietly overflowed: " + result2);
</code>```

答:
Int to Short is a type conversion, and java requires explicit casts even where
the type conversion could be deduced automatically.

Java's lax treatment of incorrect results from integer arithmetic is a separate
matter.  It's a very good question why integer overflow doesn't cause a runtime
exception.


答: In the first case, the compiler knows that you're facing a potential loss of precision, so it can stop you. In the second case the overflow happens during a runtime calculation - though your example trivialy causes an overflow, there is no way for the compiler to check such occurrences in general case so it doesn't.</p>

Title: Why disallow int-to-short assignment but allow multiplication and other math?

Body:
In Java, the following code does not compile:

```<code>int val = 1;
short shortVal = val;  // Incompatible types
</code>```

Anyone know why Java chooses to complain about this assignment, instead of simply truncating, when an integer × integer is also likely to overflow?

To illustrate:

```<code>int val = 46340;
int result = val * val;                    // 2147395600
System.out.println(result);
int overflowVal = 46341;
int result2 = overflowVal * overflowVal;   // -2147479015
System.out.println("Quietly overflowed: " + result2);
</code>```


问:
How to handle errors back in an API environment
We're discussing the best way to handle errors in calls to a method.

We have a credit model where we allow users to deduct credits for certain actions.  We'd like to make a call to:

```<code>User.DeductCredits(10);
</code>```

Then the Deduct method will check things like

Does the user exist?

Is the user active?

Does the user have at least 10 credits?

If not, this result should fail.

We're currently writing this just as a class library, but trying to keep it open to convert to a web service in the future.  The options we've discussed so far are:

Throw an exception when an error occurs.

Create a new Result object that would have T has the type of data expected back, and wrapping that with a status code and message.

We didn't like option #1, because then code to call deduct credits would look something like:

```<code>try
{
   user.DeductCredits(10);
}
catch(InvalidUserException e)
{
}
catch(InactiveUserException e)
{
}
catch(CreditBalanceException e)
{
}
</code>```

Additionally, if we turn this in to a service, we can't force exceptions on the user.

The main reason we didn't like option #2 was that it seemed to be returning more data than what we need.  For example:

```<code>  var address = user.GetMailAddress();
</code>```

Now address has the status code and message, as well as a data property, or value property.  So to get the city, you'd have code like:

```<code>if(!address.HasError)
   state = address.Data.State;
</code>```

as opposed to:

```<code>state = address.State;
</code>```

So is there a best practice for this type of situation?  Is one option really any better than the other?

答:
The best practice is a combination of the two: if it is a real error, (something that should not really happen,) then you should throw an exception.  If it is not a real error, but something that may happen within the regular course of things, then the function should return some sort of a result enum. In your case, without knowing the specifics and just guessing from the names I see, it seems to me that "invalid user" is an error, so an exception should be thrown, while "inactive user" and "insufficient funds" are probably not errors, but results.

I assume that by "user" you mean the programmer who will be using your service. In my book, "we can't force exceptions on the user" is just plain dead wrong. You must force exceptions on the user; as a matter of fact, the user expects exceptions when things go wrong. That's the way things are done in this millennium. Also, do not worry, you will very rarely, if ever, need to write multiple catch statements for all possible exceptions. Try it, and you will see that in actual usage scenarios things do not work that way.


问:
Hiring programmers for small companies?
I've been running a company for nearly 10 years, and all this time it's been just myself, another programmer (who's a great friend and cofounder), and a salesman (who's also a friend). Together, we've managed to do decent business and we've all managed to make a living, but we've been trying to expand for a long time now.

Unfortunately, there are a few problems:

The technology we use is not obsolete, but it's also not as popular
compared to other web development options like PHP

We work in a competitive market, competing against multi-million
dollar companies

We can't afford to pay new programmers or salesmen very well. We make
enough money for ourselves, but unless we got a significant number of
new customers we wouldn't be able to pay much.

Because of the fact we can't pay much, we use a slightly more rare
technology, and we compete against large companies, we find it
difficult to find new programmers or salesman.

We desperately need to expand, but when we try to get more customers, we can't support them with so few people (or their demands grow outside of our range of expertise) and when we try to hire new programmers and salesman, we usually don't get a high quality and they usually don't provide a major benefit for our company.

Does anyone have some suggestions or tips on how we could expand?

答:
I'll start with the hard truth: If your business model only works as long as you can get an expensive resource (developer talent) for a price lower than the market price, then you don't have a business model. The fact that you're competing against larger companies isn't an excuse. In the development field, larger organizations typically have higher costs per "development unit" than smaller ones (Diseconomy of scale). So you should be able to offer your programmers a higher salary than those larger companies, where every developer has to "pull" for one or two managers, secretaries, HR people and the likes.

That said, I think the best thing you can do in the short run is to hire programmers with little or no experience. Think high-school graduate who liked to play around with Python in his free time. The implicit deal would be: They work for a low salary and in turn you teach them professional programming, good practices, how to deal with customers and so on.

Title: Hiring programmers for small companies?


问:
Graduate expectations versus reality
When choosing what we want to study, and do with our careers and lives, we all have some expectations of what it is going to be like. Now that I've been in the industry for almost a decade, I've been reflecting a bit on what I thought (back when I was studying Computer Science) programming working life was going to be like, and how it's actually turning out to be.

My two biggest shocks (or should I say, broken expectations) by far are the sheer amount of maintenance work involved in software, and the overall lack of professionalism:

Maintenance: At uni, we were all told that the majority of software work is maintenance of existing systems. So I knew to expect this in the abstract. But I never imagined exactly how overwhelming this would turn out to be. Perhaps it's something I mentally glazed over, and hoped I'd be building cool new stuff from scratch a lot more. But it really is the case that most jobs are overwhelmingly maintenance, bug fixing, and support oriented.

Lack of professionalism: At uni, I always had the impression that commercial software work is very process-oriented and stringently engineered. I had images of ISO processes, reams of technical documentation, every feature and bug being strictly documented, and a generally professional environment. It came as a huge shock to realise that most software companies operate no differently to a team of students working on a large semester-long project. And I've worked in both the small agile hack shop, and the medium sized corporate enterprise. While I wouldn't say that it's always been outright "unprofessional", it definitely feels like the software industry (on the whole) is far from the strong engineering discipline that I expected it to be.

Has anyone else had similar experiences to this? What are the ways in which your expectations of what our profession would be like were different to the reality?

答:
Computer programming is non-physical and non-intuitive.

When a house builder finishes his/her work, s/he can walk around and immediately see/feel if there is anything wrong. A computer programming bug cannot be discovered in the same way, and may lurk in the system for months, or even decades.

While a programmer may look/feel a piece of source code through code review, it is not guaranteed to spot every error contained in the code. A computer, however, would be able to exactly reproduce the error every time by executing the program with certain input. Thus, human understanding of a piece of source code is always an imperfect model of the essense of it being the instructions to a computer.

It is very easy to code a program that handles the most common cases, but completely fails to handle the edge cases.

In other disciplines, it is relatively easy to apply a remedial action after-the-fact. There may even be a body-of-knowledge specifically devoted to remedial actions. There is no such thing in Software Development.

Fortunately, test-driven development helps codify the edge cases that the code is supposed to handle.

Added On the other hand, certain software development methodologies seem to suggest that we can extract business value (faster time to market, etc.) by consciously choosing not to handle edge cases, and to communicate those decisions to the customers.

Customers may find business values in a software that handles only the most common cases, therefore software providers are not too concerned about handling the rare cases.

Customers simply learn to avoid the rough edges.

Added

The elegance of the source code is not valued.

Customers do not see the elegance of the source code. They only see the elegance of the user interface and interactions.

Programmers, on the other hand, usually do not value the elegance of the user interface, and they usually do not remain in a single project for a long enough time to start appreciating an elegant software design.

Because neither customers nor programmers value the elegance of the source code, neither will it be valued by businesses.

Added

My two cents: just get used to it.

Title: Graduate expectations versus reality


答:
I vote for number 1: throw exceptions.

And no, your code shouldn't try to capture all possible exceptions. You should create code to avoid most of those exceptions if you can handle it. Instead of your example, consider this:

```<code>if (user.Credits >= 10) { user.DeductCredits(10); }
</code>```

When your application arrives at this part of the code you should already be certain that the user exists otherwise what would there be in that user variable?

Title: How to handle errors back in an API environment

Body:
We're discussing the best way to handle errors in calls to a method.

We have a credit model where we allow users to deduct credits for certain actions.  We'd like to make a call to:

```<code>User.DeductCredits(10);
</code>```

Then the Deduct method will check things like

Does the user exist?

Is the user active?

Does the user have at least 10 credits?

If not, this result should fail.

We're currently writing this just as a class library, but trying to keep it open to convert to a web service in the future.  The options we've discussed so far are:

Throw an exception when an error occurs.

Create a new Result object that would have T has the type of data expected back, and wrapping that with a status code and message.

We didn't like option #1, because then code to call deduct credits would look something like:

```<code>try
{
   user.DeductCredits(10);
}
catch(InvalidUserException e)
{
}
catch(InactiveUserException e)
{
}
catch(CreditBalanceException e)
{
}
</code>```

Additionally, if we turn this in to a service, we can't force exceptions on the user.

The main reason we didn't like option #2 was that it seemed to be returning more data than what we need.  For example:

```<code>  var address = user.GetMailAddress();
</code>```

Now address has the status code and message, as well as a data property, or value property.  So to get the city, you'd have code like:

```<code>if(!address.HasError)
   state = address.Data.State;
</code>```

as opposed to:

```<code>state = address.State;
</code>```

So is there a best practice for this type of situation?  Is one option really any better than the other?

Body:
I vote for number 1: throw exceptions.

And no, your code shouldn't try to capture all possible exceptions. You should create code to avoid most of those exceptions if you can handle it. Instead of your example, consider this:

if (user.Credits >= 10) { user.DeductCredits(10); }

When your application arrives at this part of the code you should already be certain that the user exists otherwise what would there be in that user variable?


答: Knowledge of specific technologies and syntax isnt the most important factor in a world where those technologies change every couple of years.  It sounds like they pre-filtered you on the phone with some tech questions to make sure you were a legitimate candidate, and then when in person, were trying to learn what kind of programmer you are and what kind of decisions you make.  In the long run, having someone who makes good decisions is far more important than someone who knows programming language syntax.


答:
Since your budget is very limited, I would do several things :

search for someone with low or no experience

offer them company's share, or a percent of the profit

Title: Hiring programmers for small companies?

Body:
I've been running a company for nearly 10 years, and all this time it's been just myself, another programmer (who's a great friend and cofounder), and a salesman (who's also a friend). Together, we've managed to do decent business and we've all managed to make a living, but we've been trying to expand for a long time now.

Unfortunately, there are a few problems:

The technology we use is not obsolete, but it's also not as popular
compared to other web development options like PHP

We work in a competitive market, competing against multi-million
dollar companies

We can't afford to pay new programmers or salesmen very well. We make
enough money for ourselves, but unless we got a significant number of
new customers we wouldn't be able to pay much.

Because of the fact we can't pay much, we use a slightly more rare
technology, and we compete against large companies, we find it
difficult to find new programmers or salesman.

We desperately need to expand, but when we try to get more customers, we can't support them with so few people (or their demands grow outside of our range of expertise) and when we try to hire new programmers and salesman, we usually don't get a high quality and they usually don't provide a major benefit for our company.

Does anyone have some suggestions or tips on how we could expand?


答: Type mismatch in a calculation is not really an issue, since the result of the calculation is still definable even for operands of different bit sizes. The issue of arithmetic overflow at runtime is more general, as it can happen even in calculations among same bit size operands, and there clearly is no point to have the compiler warn us about the possibility that we may have an overflow every time we increment an integer. So, the question boils down to why does java not offer something like the 'checked' keyword of C# so as to offer the possibility of catching arithmetic overflow at runtime. But that would be the subject of a different question.</p>


答:
I ask these kind of question because being able to code or solve technical problems is only a basic foundation of how you are going to do in the company. The interviewer was testing communication, motivation and behavior.

The interviewer in your case seems to be interested in:

Can this person communicate with his teammates effectively to work as
a team?

Does this person have an genuine interest in the IT industry and truly love what he is doing.

Would this person be pleasant to work with?

Language skills are not a criteria.

However, if you have trouble describing your project and interests, I would have doubts about your ability to follow complex discussions and whiteboard session (over noisy conference bridge) or present your design and solutions to teammates and managers.

Technical skills are a bar you have to pass through to be competent, but good communication combined with a genuine motivate are what truly makes you outstanding in the long term, and that is what we care about the most.

Disclaimer: I do not speak for Amazon policy in any way and the statement above is purely my personal opinion.