答:
I personally prefer to separate different areas of concern between several assemblies instead of bundling everything together into a single executable.

Typically, I prefer to keep an absolute minimal quantity of code in the application's entry point - No business logic, no GUI code and no data access (databases/file access/network connections/etc);  I usually limit the entry point code (i.e. the executable) to something along the lines of

Creating and Initialising the various application components from all of the dependent assemblies

Configuring any 3rd party components which the whole application depends on (e.g. Log4Net for diagnostic output)

also I'll probably include a "catch all exceptions and record the stack trace" type bit of code in the main function which will help log the circumstances of any unforseen critical/fatal failures.

As for the application components themselves, I usually aim for at least three in a small application

Data Access Layer (database connections, file access, etc) - depending on the complexity of any persistant/stored data used by the application, there might be several of these assemblies - I probably would create a separate assembly for database handling (Possibly even multiple assemblies if interacting with the database involved anything complex - e.g. if you're stucx with a badly designed database, you may need to handle DB relationships in code, therefore it might make sense to write multiple modules for insertion and retrieval)

Logic Layer - the main "meat" containing all of the decisions and algorithms which make your application work.    These decisions should know absolutely nothing about the GUI (who says there's a GUI?), and should know absolutely nothing about the database (Huh? There's a database? why not a file?).   A well-designed logic layer can hopefully be "ripped out" and dropped into another application without needing to be re-compiled.   In a complicated application, there might be a whole bunch of these logic assemblies (because you may just want to rip out 'pieces' without dragging along the rest of the application)

Presentation layer (i.e. the GUI); In a small application, there might just be a single "main form" with a couple of dialog boxes which can all go into a single assembly - in a bigger application, there might be separate assemblies for whole functional parts of the GUI.   The classes here will do little more than make the user interaction work - it'll be little more than a shell with some basic input validation, handling any animation, etc.  Any events/button clicks which "do something" will be passed forward to the logic layer (so my presentation layer will strictly contain no application logic whatsoever, but it will also not place the burden of any GUI code on the logic layer either - so any progress bars or other fancy stuff will also sit in the presentation assembly/ies)

My main rationale for splitting the Presentation, Logic and Data layers to separate assemblies is this: I feel that it's preferable to be able to run the main application logic without your database or your GUI.

To put it another way; if I want to write another executable which behaves in exactly the same way as your application, but uses a commandline interface, or a web interface;  and swaps the database storage for file storage (or a different kind of database maybe), then I can do so without needing to touch the main application logic at all - all I'd need to do is write a little a command-line tool and another data model, then "plug it all together", and I'm ready to go.

You may be thinking "Well I'm never going to want to do any of that so it doesn't matter if I can't swap these things around" - the real point is that one of the hallmarks of a modular application is the ability to extract 'chunks' (Without needing to re-compile anything), and re-use those chunks elsewhere.  In order to write code like this, it generally forces you to think long and hard about design principles - You'll need to think about writing a lot more interfaces, and think carefully about the trade-offs of various S.O.L.I.D principles (In the same way as you would for Behaviour-Driven-Development or TDD)

Sometimes achieving this separation from an existing monolithic lump of code is a little painful and requires a lot of careful refactoring - that's OK, you should be able to do it incrementally - you may even reach a point where there are too many assemblies and you decide to go back the other way and start wrapping things up together again (going too far in the opposite direction can have the effect of making those assemblies rather useless on their own)


问:
Was API hooking done as needed for Stuxnet to work? I don't think so
Caveat: I am a political science student and I have tried my level best to understand the technicalities; if I still sound naive please overlook that.

In the Symantec report on Stuxnet, the authors say that once the worm infects the 32-bit Windows computer which has a WINCC setup on it, Stuxnet does many things and that it specifically hooks the function CreateFileA(). This function is the route which the worm uses to actually infect the .s7p project files that are used to program the PLCs. ie when the PLC programmer opens a file with .s7p the control transfers to the hooked function CreateFileA_hook() instead of CreateFileA(). Once Stuxnet gains the control it covertly inserts code blocks into the PLC without the programmers knowledge and hides it from his view.

However, it should be noted that there is also one more function called CreateFileW() which does the same task as CreateFileA() but both work on different character sets. CreateFileA works with ASCII character set and CreateFileW works with wide characters or Unicode character set. Farsi (the language of the Iranians) is a language that needs unicode character set and not ASCII Characters. I'm assuming that the developers of any famous commercial software (for ex. WinCC) that will be sold in many countries will take 'Localization' and/or 'Internationalization' into consideration while it is being developed in order to make the product fail-safe ie. the software developers would use UNICODE while compiling their code and not just 'ASCII'. Thus, I think that CreateFileW() would have been invoked on a WINCC system in Iran instead of CreateFileA(). Do you agree?

My question is: If Stuxnet has hooked only the function CreateFileA() then based on the above assumption there is a significant chance that it did not work at all? I think my doubt will get clarified if: my assumption is proved wrong, or the Symantec report is proved incorrect. Please help me clarify this doubt.

Edit: For more clarity of my question and what I'm looking for.

Is it possible that the WinCC STL Editor be programmed in the following way?

```<code>//Pseudocode Begins
if (locale == ASCII Dependent) //like US, UK, Australia etc.
{
     CreateFileA(); //with appropriate parameters
}
else if (locale == UNICODE Dependent) //like Middle East, China, Japan etc
{
     CreateFileW(); //with appropriate parameters
} //Pseudocode ends
</code>```

If it is possible then does it follows that Stuxnet would work appropriately in the US but not in China or Japan or Iran?

答:
Note that CreateFileA and CreateFileW differ only in the character set of the filename itself. The actual contents of the file are just bytes in both cases, and free to be interpreted by the program in whatever way it likes.

In fact, in all modern Windows, the *A functions are typically just very thin wrappers around the *W functions where all they do is convert the arguments to/from Unicode.

ContentLicense: CC BY-SA 3.0


问:
Performance analysis of C++ programs
How can I measure the performance of my C++ programs using C++?

Specific metrics I want to measure are:

Memory used (space)

Duration taken (time)

答:
For measuring space, I'll defer to other answers.

For time, I have to ask, are you measuring just because you want to measure, or because you want to make the program take less time?

I only ask because measuring time, even of individual functions, does not tell what you should fix to make it run faster.
It may tell you where you shouldn't look (i.e. functions with low inclusive percent), but that doesn't tell you where you should concentrate.
To do that, here's the method I use.

Title: Performance analysis of C++ programs


答:
I'm assuming that the developers of any famous commercial software (for ex. WinCC) that will be sold in many countries will take 'Localization' and/or 'Internationalization' into consideration while it is being developed in order to make the product fail-safe ie. the software developers would use UNICODE while compiling their code and not just 'ASCII'. Thus, I think that CreateFileW() would have been invoked on a WINCC system in Iran instead of CreateFileA(). Do you agree?

Today, yes. But WinCC was first introduced in 1995. Back then, Unicode was still quite new and it wasn't common that programs supported unicode. Among other reasons, so they would be run on Windows 95/98/ME, which never supported unicode.

Instead, people used codepages to display non-latin characters: Simply put, you'd tell the OS that your process was using codepage 1256 now and the operating system would display characters in the 128..255 range as farsi characters (if you have the right fonts).

My question is: If Stuxnet has hooked only the function CreateFileA() then based on the above assumption there is a significant chance that it did not work at all?

Whoever created Stuxnet didn't just write a worm that would hook into CreateFileA and hope WinCC would call CreateFileA eventually. I'm sure they had a copy of exactly the version of WinCC they were targeting. They probably debugged it to find out which function to hook into. If WinCC would have been built using unicode, they'd have hooked into CreateFileW instead.

Title: Was API hooking done as needed for Stuxnet to work? I don't think so

Body:
Caveat: I am a political science student and I have tried my level best to understand the technicalities; if I still sound naive please overlook that.

In the Symantec report on Stuxnet, the authors say that once the worm infects the 32-bit Windows computer which has a WINCC setup on it, Stuxnet does many things and that it specifically hooks the function CreateFileA(). This function is the route which the worm uses to actually infect the .s7p project files that are used to program the PLCs. ie when the PLC programmer opens a file with .s7p the control transfers to the hooked function CreateFileA_hook() instead of CreateFileA(). Once Stuxnet gains the control it covertly inserts code blocks into the PLC without the programmers knowledge and hides it from his view.

However, it should be noted that there is also one more function called CreateFileW() which does the same task as CreateFileA() but both work on different character sets. CreateFileA works with ASCII character set and CreateFileW works with wide characters or Unicode character set. Farsi (the language of the Iranians) is a language that needs unicode character set and not ASCII Characters. I'm assuming that the developers of any famous commercial software (for ex. WinCC) that will be sold in many countries will take 'Localization' and/or 'Internationalization' into consideration while it is being developed in order to make the product fail-safe ie. the software developers would use UNICODE while compiling their code and not just 'ASCII'. Thus, I think that CreateFileW() would have been invoked on a WINCC system in Iran instead of CreateFileA(). Do you agree?

My question is: If Stuxnet has hooked only the function CreateFileA() then based on the above assumption there is a significant chance that it did not work at all? I think my doubt will get clarified if: my assumption is proved wrong, or the Symantec report is proved incorrect. Please help me clarify this doubt.

Edit: For more clarity of my question and what I'm looking for.

Is it possible that the WinCC STL Editor be programmed in the following way?

```<code>//Pseudocode Begins
if (locale == ASCII Dependent) //like US, UK, Australia etc.
{
     CreateFileA(); //with appropriate parameters
}
else if (locale == UNICODE Dependent) //like Middle East, China, Japan etc
{
     CreateFileW(); //with appropriate parameters
} //Pseudocode ends
</code>```

If it is possible then does it follows that Stuxnet would work appropriately in the US but not in China or Japan or Iran?


问:
Is it right to appraise Scrum members according to number of successful user stories completed?
When my Manager told to team that "from now on successful user stories will be considered for appraisal!"

We sat there for while shocked and that was one of the several jaw dropping moments he gave us.

We felt that was stupid idea, since this will ruin all concept and goal of agile development methodology.

Let me know what you people think? And how can we convince him?

答:
This is on a par to measuring lines of code, or number of bugs - but slightly more sophisticated.

At first glance there's nothing wrong with the measurement, but when you think about it you start raising objections:

what about more complicated stories?

is the most obvious one that springs to mind - I'm sure there are others.

Your manager obviously thinks this is a good idea, so you need to be careful that when you raise objections you can also present solutions. This solution might have to be a modification to his scheme rather than a new scheme.

So for example you might want to point out that someone who just works on "easy" stories will complete more than someone who works on a more "difficult" one and this might lead to a concentration on the less important aspects of the development. So one solution might be to consider the number of story points rather than just the number of stories.

ContentLicense: CC BY-SA 4.0


问:
Can an issue tracking system be distributed?
I was thinking about issue tracking software like Redmine, Trac or even the one that is in Fossil and something hit me:

Is there a reason why Redmine and Trac are not possible to be distributed?
Or maybe it's possible and I just don't know how it's possible?

If it's not possible, why?

By distributed I mean like Facebook or Google or other applications that effectively runs on multiple hardware a the same time but share data.

答:
Both Redmine and TRAC are typical web based CRUD applications, architecturally wise, there isn't a reason why they can't be distributed. The simplest way would be to have them use a distributed database, and since both support MySQL the obvious solution would be MySQL Cluster.

Then of course you could save yourself any hassle and run them on a cloud, for example BitNami offers a Redmine stack for Amazon EC2 via ready made Amazon Machine Images. Nowadays, almost every hosted issue tracker has moved to a cloud, letting cloud vendors deal with the nuances of load balancing, etc.

To summarize: Any web application can be distributed, whether it's the whole application or just it's data store that's distributed, there isn't really a technical restriction. It's simply a question of resources, either you need them or you don't.


答:
For duration (time) I would also use a profiler. However, if you want to track
certain methods in particular, I have used the trick of defining a small
timer class that starts a timer in the constructor and stops it in the
destructor. Then all you need to do is to define a local timer variable
at the beginning of the methods you want to profile, like this:

```<code>MyClass::myMethod()
{
    MyTimer timer("MyClass::myMethod");

    ...
}
</code>```

The destructor of the timer variable will log the name of the method and
the duration when you exit the method.

Yes, using a profiler is much cleaner and you don't need to changed the code
(even though I normally add the timer variables in a separate copy of
the source code so no clean-up is needed afterwards) but I found this
method an effective alternative to using a profiler if the code you want
to profile is very localized.

Just my 2 cents.

Title: Performance analysis of C++ programs

Body:
How can I measure the performance of my C++ programs using C++?

Specific metrics I want to measure are:

Memory used (space)

Duration taken (time)

Body:
For duration (time) I would also use a profiler. However, if you want to track
certain methods in particular, I have used the trick of defining a small
timer class that starts a timer in the constructor and stops it in the
destructor. Then all you need to do is to define a local timer variable
at the beginning of the methods you want to profile, like this:

MyClass::myMethod()
{
    MyTimer timer("MyClass::myMethod");

    ...
}

The destructor of the timer variable will log the name of the method and
the duration when you exit the method.

Yes, using a profiler is much cleaner and you don't need to changed the code
(even though I normally add the timer variables in a separate copy of
the source code so no clean-up is needed afterwards) but I found this
method an effective alternative to using a profiler if the code you want
to profile is very localized.

Just my 2 cents.


答:
I am sure you must have a very good reason to profile your C++ program using another C++ program. If you are in Linux, I suggest you look into details of the /proc filesystem and files like meminfo which the OS maintains tracking your runtime memory usage. </p>

<p>If you are in the mood to explore tools that can take a lot of hard work to develop on your own I suggest you look into Quantify, VTune, Valgrind etc. </p>

Title: Performance analysis of C++ programs

Body:
I am sure you must have a very good reason to profile your C++ program using another C++ program. If you are in Linux, I suggest you look into details of the /proc filesystem and files like meminfo which the OS maintains tracking your runtime memory usage.

If you are in the mood to explore tools that can take a lot of hard work to develop on your own I suggest you look into Quantify, VTune, Valgrind etc.


问:
Designing an API on top with Java RMI and Rest APIs
I'm working on the backend of a java web application. We have a document repository (Fedora Commons specifically) where we house xml files. I want to abstract the API of the repository internally so that we aren't tightly coupled to one product. I'd also like to give the flexibility of connecting to to a repository via Java RMI or REST APIs. I was hoping to get advice or resources on how to implement something like this.

My thought it that I'd have some abstract repository class that had methods like getRecord, updateRecord, and deleteRecord. In the constructor I would pass the URI for the repository and the API method and port. This would allow some flexibility in the future so that if the REST api became more practical, but allow the flexibility or using RMI which could (should?) have better performance.

Am I over thinking this or am I on the right path?

答:
Consider using OData and REST for exposing data

There is a lot of useful information on the OData website regarding how to expose data that any OData compliant client can interpret and use. OData is based on internet standards like AtomPub, JSON, XML etc and provides a collection of useful guidelines on how to structure URIs and so on. OData clients exist for Java, iPhone, PHP, Python, C# and many others so you won't limit accessibility to a specific programming language.

The OData approach is compatible with a RESTful architecture in that the URIs are discoverable and the HATEOAS principle is followed well. There is an initial shudder when you learn that Microsoft is behind it, but that goes away when you see that it's actually an open protocol that is used by the likes of Netflix and others.

Show me the code

In terms of a workable API, take a look at some sample code from odata4j. You'll notice that it does not expose the underling REST calls, and instead works with metadata that it can derive by exploring what has been offered by the data store. This makes the client resilient to changes, such as the addition of new types of data and the relationships between them and existing data types.


答:
I think of distributed as decentralized. All the data may end up being merged with a central system, but it's not required. This allows users to work independantly for longer periods of time. Many source control systems work this way.

When individual items are worked on by one user, this is pretty easy. If multiple users want to continuously update a bug description, you could have problems with such long delays making an attempt to merge.

This reminds me of the original goal of Chandler, described in the book Dreaming in Code. Wouldn't it be great if there was a contact manager that didn't rely on a central server for groups to share notes, messages, contacts, tasks, calendars, etc. There so many online services for this, I wonder why anyone would bother. Maybe security, secrecy and "being off the Google grid" are reasons enough.

Yes, go for it.

Title: Can an issue tracking system be distributed?

Body:
I was thinking about issue tracking software like Redmine, Trac or even the one that is in Fossil and something hit me:

Is there a reason why Redmine and Trac are not possible to be distributed?
Or maybe it's possible and I just don't know how it's possible?

If it's not possible, why?

By distributed I mean like Facebook or Google or other applications that effectively runs on multiple hardware a the same time but share data.


问:
How can I explain C# interfaces, and constructors to a 8 years old kid?
How can I explain C# interfaces and constructors to a 8 years old genius kid?</p>

答:
Interfaces - the bumps on Lego/Mindstorm pieces, allowing you to connect bits to each other easily

Constructors - A method that prepares the object for usage, so perhaps a cooking analogy is a good one. Adding boiling water to soup powder in order to make soup?


问:
Rails and Mongoid best way to implement sharing system
I have to model User and Board in rails using mongoid as ODM.

Each board is referenced to an user through a foreign key user_id and now I want to add the ability to share a board with other users.

Following CRUD I'd create a new Model called something like Share and it's releated Controller with the ability to create/edit/delete a Share but I have some doubts:

First, where to save informations about Shares? I think I may create a field in the Board's collection called shared_with including an array of user ids. in a MySQL I'd created a new table with the ids of who share, the resource shared and the user the resources is shared with but I don't think that's necessary using MongoDB.

Every user a Board is shared with should be able to edit the Board (but not to delete it) so the Board should have two relations one with the owner and another with the users the board is shared with, right?

For permission (the owner should be able to delete a board but the users it is shared with shouldn't) what to use? I'm using Devise for authentication but I think something like CanCan would fit better. but how to implement it?

What do you think about this way? Do you find any problems or have better solutions?

答:
I generally agree with your solution and I would do the same, i.e. create a separate model called Share, even though it looks like a RDBMS-like solution.

But let's step back and review the available options.

First of all, consider the relations of your models. Draw them on a piece of paper and note the type of relations and their associations (belongs to, has one, has many, has many through or has_and_belongs_to_many). Perfect reference for the associations in rails is http://guides.rubyonrails.org/association_basics.html. Take into account that Mongoid also offers embedded_in/embeds_many type of relations.

In your case the relations would be: User (1..N) Boards for owning, User (N..N) Boards for sharing.

The hint to decide whether to use has_many, has_and_belongs_to_many or embeds_many is whether or not the subordinate model represents semantically embedded type of relation and is not connected with other models than its parent. It it is, use embeds_many, otherwise use has_many or has_and_belongs_to_many.

The hint to decide whether to use has_many :through or has_and_belongs_to_many is whether you are going to add more data to a linking model (Share in your case).

has_and_belongs_to_many in mongoid is doing without creation of a linking model, i.e. board_ids would be kept as an array in the User model and user_ids would be kept as an array in the Board model.

The reason to not use HABTM in your case is simple. You have two relations between your User and Board models (sharing and owning), you would have difficulty in figuring out what expression like user.boards means (shared boards or owned boards). I don't know of an easy way to separate these two kinds of relations without use of a third model (Share) as you proposed in comments (using :as, etc.)

You can also manually keep the ids of boards in your user model, like this:

```<code>class User
  include Mongoid::Document
  field :name
  key :shared_board_ids, Array, :index => true
  key :owned_board_ids, Array, :index => true

  def shared_boards
    Board.find shared_board_ids
  end
  # ...

end
</code>```

However, difficulties in this case arise pretty fast. You have to manually destroy all board references from the User model when you destroy a board. If you keep a sharing_user_ids in your Board model, you have redundancy and another set of difficulties.

So, yes, I would recommend creating a separate Share model, as I show below.

```<code>class User
  include Mongoid::Document
  field :name
  has_many :shares
  has_many :boards
end

class Board
  include Mongoid::Document
  field :title
  has_many :shares
  belongs_to :user
end

class Share
  include Mongoid::Document
  belongs_to :user
  belongs_to :board
end
</code>```

As of permissions, CanCan is simple, but it is doing just fine. Notice a difference between terms authentication (which checks the authenticity of a user, in other words checks that the user is really who he claims he is - normally using password) and authorization (which checks the rights of the user). Authentication is handled by gems like Authlogic, Warden (and Devise based on Warden), Sorcery. Authorization is handled by Declarative_authorization or CanCan.

Body:
I generally agree with your solution and I would do the same, i.e. create a separate model called Share, even though it looks like a RDBMS-like solution.

But let's step back and review the available options.

First of all, consider the relations of your models. Draw them on a piece of paper and note the type of relations and their associations (belongs to, has one, has many, has many through or has_and_belongs_to_many). Perfect reference for the associations in rails is http://guides.rubyonrails.org/association_basics.html. Take into account that Mongoid also offers embedded_in/embeds_many type of relations.

In your case the relations would be: User (1..N) Boards for owning, User (N..N) Boards for sharing.

The hint to decide whether to use has_many, has_and_belongs_to_many or embeds_many is whether or not the subordinate model represents semantically embedded type of relation and is not connected with other models than its parent. It it is, use embeds_many, otherwise use has_many or has_and_belongs_to_many.

The hint to decide whether to use has_many :through or has_and_belongs_to_many is whether you are going to add more data to a linking model (Share in your case).

has_and_belongs_to_many in mongoid is doing without creation of a linking model, i.e. board_ids would be kept as an array in the User model and user_ids would be kept as an array in the Board model.

The reason to not use HABTM in your case is simple. You have two relations between your User and Board models (sharing and owning), you would have difficulty in figuring out what expression like user.boards means (shared boards or owned boards). I don't know of an easy way to separate these two kinds of relations without use of a third model (Share) as you proposed in comments (using :as, etc.)

You can also manually keep the ids of boards in your user model, like this:

class User
  include Mongoid::Document
  field :name
  key :shared_board_ids, Array, :index => true
  key :owned_board_ids, Array, :index => true

  def shared_boards
    Board.find shared_board_ids
  end
  # ...

end

However, difficulties in this case arise pretty fast. You have to manually destroy all board references from the User model when you destroy a board. If you keep a sharing_user_ids in your Board model, you have redundancy and another set of difficulties.

So, yes, I would recommend creating a separate Share model, as I show below.

class User
  include Mongoid::Document
  field :name
  has_many :shares
  has_many :boards
end

class Board
  include Mongoid::Document
  field :title
  has_many :shares
  belongs_to :user
end

class Share
  include Mongoid::Document
  belongs_to :user
  belongs_to :board
end

As of permissions, CanCan is simple, but it is doing just fine. Notice a difference between terms authentication (which checks the authenticity of a user, in other words checks that the user is really who he claims he is - normally using password) and authorization (which checks the rights of the user). Authentication is handled by gems like Authlogic, Warden (and Devise based on Warden), Sorcery. Authorization is handled by Declarative_authorization or CanCan.


答:
For the profiling side of things, as long as you are using GNU, you can use gprof.  It will give you results like this:

Each sample counts as 0.01 seconds.

```<code>  %   cumulative   self              self     total
 time   seconds   seconds    calls  ms/call  ms/call  name
 33.34      0.02     0.02     7208     0.00     0.00  open
 16.67      0.03     0.01      244     0.04     0.12  offtime
 16.67      0.04     0.01        8     1.25     1.25  memccpy
 16.67      0.05     0.01        7     1.43     1.43  write
 16.67      0.06     0.01                             mcount
  0.00      0.06     0.00      236     0.00     0.00  tzset
  0.00      0.06     0.00      192     0.00     0.00  tolower
  0.00      0.06     0.00       47     0.00     0.00  strlen
  0.00      0.06     0.00       45     0.00     0.00  strchr
  0.00      0.06     0.00        1     0.00    50.00  main
  0.00      0.06     0.00        1     0.00     0.00  memcpy
  0.00      0.06     0.00        1     0.00    10.11  print
  0.00      0.06     0.00        1     0.00     0.00  profil
  0.00      0.06     0.00        1     0.00    50.00  report
</code>```

Link To data

THe great thing about this is that it has all functions in the system traced so that you get an accurate view of which function to look at.

Title: Performance analysis of C++ programs

Body:
For the profiling side of things, as long as you are using GNU, you can use gprof.  It will give you results like this:

Each sample counts as 0.01 seconds.

  %   cumulative   self              self     total
 time   seconds   seconds    calls  ms/call  ms/call  name
 33.34      0.02     0.02     7208     0.00     0.00  open
 16.67      0.03     0.01      244     0.04     0.12  offtime
 16.67      0.04     0.01        8     1.25     1.25  memccpy
 16.67      0.05     0.01        7     1.43     1.43  write
 16.67      0.06     0.01                             mcount
  0.00      0.06     0.00      236     0.00     0.00  tzset
  0.00      0.06     0.00      192     0.00     0.00  tolower
  0.00      0.06     0.00       47     0.00     0.00  strlen
  0.00      0.06     0.00       45     0.00     0.00  strchr
  0.00      0.06     0.00        1     0.00    50.00  main
  0.00      0.06     0.00        1     0.00     0.00  memcpy
  0.00      0.06     0.00        1     0.00    10.11  print
  0.00      0.06     0.00        1     0.00     0.00  profil
  0.00      0.06     0.00        1     0.00    50.00  report

Link To data

THe great thing about this is that it has all functions in the system traced so that you get an accurate view of which function to look at.


答:
You point the kid to the appropriate MSDN pages. If he's a genius, it'll suffice ;)

Otherwise sit down with him, write some simple code showcasing both. The same console examples you would show a grown-up. Nothing fancy, just some lines printed in constructors to show how an object graph is created and maybe the classic animal example for the interfaces (the one with different animals implementing a Speak or Move method).

If the kid is genuinely interested in programming, that will keep him entertained. If he'll lose interest after a few minutes, let him be. Have a normal childhood. Give him the "interface talk" when he'll grow up a bit.

Title: How can I explain C# interfaces, and constructors to a 8 years old kid?

Body: How can I explain C# interfaces and constructors to a 8 years old genius kid?</p>


答:
I would get them one of these toys:

And would make an analogy that the yellow piece on top has holes in it with a specific shape, and the shapes that you are allowed to pass through these holes is a concrete type of that shape. The interface, although is not creating any action on the shape, implies that the shape has to have a few characteristics, like size, how many sides, is it round, etc.

As for the constructor, I'd tell them it's the "recipe" + action of building one of these little toys: (a) It's something that is specific for that type of toy; (b) it can be applied to other toys that are similar to first toy; (c) I can build it slightly different next time, like changing the color or having it's height different from the original height; etc.

So after these analogies, I could point to the code (assuming you're showing code to your kid) showing the interface not interfering with the concrete class behavior, tells the class some of the features it should have, and the constructor of the class is the subroutine of building that type.

Makes sense?


问:
Does LINQ require significantly more processing cycles and memory than lower-level data iteration techniques?

Background

I am recently in the process of enduring grueling tech interviews for positions that use the .NET stack, some of which include silly questions like this one, and some questions that are more valid.  I recently came across an issue that may be valid but I want to check with the community here to be sure.

When asked by an interviewer how I would count the frequency of words in a text document and rank the results, I answered that I would

Use a stream object put the text file in memory as a string.

Split the string into an array on spaces while ignoring punctuation.

Use LINQ against the array to .GroupBy() and .Count(), then OrderBy() said count.

I got this answer wrong for two reasons:

Streaming an entire text file into memory could be disasterous.  What if it was an entire encyclopedia?  Instead I should stream one block at a time and begin building a hash table.

LINQ is too expensive and requires too many processing cycles.  I should have built a hash table instead and, for each iteration, only added a word to the hash table if it didn't otherwise exist and then increment it's count.

The first reason seems, well, reasonable.  But the second gives me more pause.  I thought that one of the selling points of LINQ is that it simply abstracts away lower-level operations like hash tables but that, under the veil, it is still the same implementation.

Question

Aside from a few additional processing cycles to call any abstracted methods, does LINQ require significantly more processing cycles to accomplish a given data iteration task than a lower-level task (such as building a hash table) would?

答:
I'd say the main weakness of this answer is less its use of Linq and more the specific operators chosen. GroupBy takes each element and projects it to a key and a value which go into a lookup. In other words, every word will add something to the lookup.

The naive implementation .GroupBy(e => e) will store a copy of every word in the source material, making the final lookup nearly as large as the original source material. Even if we project out the value with .GroupBy(e => e, e => null) we're creating a large lookup of small values.

What we would want is an operator that preserves only the needed information, which is one copy of each word and the count of that word so far. For that, we can use Aggregate:

```<code>words.Aggregate(new Dictionary<string, int>(), (counts, word) =>
{
    int currentCount;
    counts.TryGetValue(word, currentCount);
    counts[word] = currentCount + 1;
    return counts;
}
</code>```

From here, there are several ways we could attempt to make this faster:

Instead of creating many strings while splitting, we could pass around structs that reference the original string and the segment that contains the word, and only copy the segment out when it turns out to be a unique key

Use Parallel Linq to aggregate across several cores then combine the results. This is trivial compared to the leg work required for doing this by hand.

Body:
I'd say the main weakness of this answer is less its use of Linq and more the specific operators chosen. GroupBy takes each element and projects it to a key and a value which go into a lookup. In other words, every word will add something to the lookup.

The naive implementation .GroupBy(e => e) will store a copy of every word in the source material, making the final lookup nearly as large as the original source material. Even if we project out the value with .GroupBy(e => e, e => null) we're creating a large lookup of small values.

What we would want is an operator that preserves only the needed information, which is one copy of each word and the count of that word so far. For that, we can use Aggregate:

words.Aggregate(new Dictionary<string, int>(), (counts, word) =>
{
    int currentCount;
    counts.TryGetValue(word, currentCount);
    counts[word] = currentCount + 1;
    return counts;
}

From here, there are several ways we could attempt to make this faster:

Instead of creating many strings while splitting, we could pass around structs that reference the original string and the segment that contains the word, and only copy the segment out when it turns out to be a unique key

Use Parallel Linq to aggregate across several cores then combine the results. This is trivial compared to the leg work required for doing this by hand.


问:
question related to iPhone programming certification
Dear All,
               I am working for iOS application developement. Now am considering to go for certification in iOS application development. I am thinking about expertrating.com. Please guide me if you know any other certification in iOS development with more market value of the certification. Thanks in advance and have a great life ahead.</p>

答: The de-facto iOS developer certification is to have one or more non-trivial apps, which you wrote, actually available in Apple's iOS App store.  Interviewing companies have been known to download the apps of candidates to try them out.  Apps that use a good cross-section of iOS technologies help.  Good user reviews for these apps also helps.  No other rating or certification currently seems to have anywhere near as much market value, if any.</p>


答:
Is your bug list so dynamic and frequently queried that you actually need to use distributed computing to manage it?

I seriously doubt that you need to do this.


问:
Should classes from the same namespace be kept in the same assembly?
For example, ISerializable and the Serializable Attribute are both in the System.Runtime.Serialization namespace, but not the assembly of the same name. On the other hand, DataContract attributes are in the namespace/assembly System.Runtime.Serialization.

This causes confusion when a class can have using System.Runtime.Serialization but still not have reference to the System.Runtime.Serialization assembly, meaning DataContract cannot be found.

Should this be avoided in practice, or is it common for namespaces to be split over multiple assemblies? What other issues should one be careful of when doing this?

答:
Namespaces are units of logical grouping.

Assemblies are units of physical grouping.

That is, break things into different assemblies only if they are going to be deployed separately.

With the example you have given, one may want to use ISerializable and Serializable without dragging in DataContract, but if one does use DataContract, it logically belongs to the same place as it deals with serialization.


问:
Commenting Code AS3 - Not being an API
How should I comment a method?

What are the best practices on commenting code?

Example:

```<code>/* Checks if a color is allowed in a given point
* of the bitmapdata of the current floor
* @param value - color to be checked
* @return boolean - if color is allowed returns true, else, return false
*/

private function isAllowed(value:uint):Boolean {

   //code...

}
</code>```

Is that the best way to comment a method?

I´ve heard there´s the use of the tag @see. What should be on this tag?
I wonder if it could be something that has a relation to the method, is that right?

Thanks.

答:
The best way to comment a method is to follow the existing standard in the project you're working in.

In new projects where you have control, the syntax you've got above is fine.

For that particular method, renaming it to isColorAllowed() would obviate the need for any function header at all, presuming that there is no existing standard about such things.

Title: Commenting Code AS3 - Not being an API


问:
On a queue, which end is the "head"?
I had always thought that the "head" of a queue as the next element to be read, and never really questioned that usage. So a linked-list library I wrote, which is used for maintaining queues, codified that terminology: we have a list1_head macro that retrieves the first element; when using this library in a queue, this will be the first element to be removed.

But a new developer on the team was used to having queues implemented the other way around. He described a queue as behaving like a dog: you insert at the head, and remove at the tail. This is a clever enough description that I feel like his usage must be more widespread, and I don't have a similarly evocative description of my preferred usage.

So, I guess, there are two related questions: 1, what does the "head" of a queue mean to you? and 2, why do we use the word "head" to describe that concept?

答:
You enter at the back of the queue, and leave from the front. In most societies, that would imply the head is the front, and items are removed from the head.

The Javadoc for Queue seems to agree with the classic definition (i.e. your original one):

Whatever the ordering used, the head of the queue is that element which would be removed by a call to remove() or poll(). In a FIFO queue, all new elements are inserted at the tail of the queue.

Title: On a queue, which end is the "head"?


问:
What is sequential code execution?
I have been looking around on the internet and have not found a good answer yet.  If anyone could be so kind and supply a code sample I would greatly appreciate it. I apologize for the simplicity of the question.  </p>

答:
This is the simplest one of all: it's when your instructions are executed in the same order that they appear in your program, without repeating or skipping any instructions from the sequence.

For example, this is sequential execution:

```<code>int a = 5;
int b = 12;
int c = a*a + b + 7;
</code>```

On the other hand, this is not sequential execution, because one instruction is going to be skipped.

```<code>int a = 5;
int b = 12;
int c;
if (a > b) {
    c = a;
} else {
    c = b;
}
</code>```

Title: What is sequential code execution?

Body:
This is the simplest one of all: it's when your instructions are executed in the same order that they appear in your program, without repeating or skipping any instructions from the sequence.

For example, this is sequential execution:

int a = 5;
int b = 12;
int c = a*a + b + 7;

On the other hand, this is not sequential execution, because one instruction is going to be skipped.

int a = 5;
int b = 12;
int c;
if (a > b) {
    c = a;
} else {
    c = b;
}


答: Sequential code means that it is accessed by a single thread. This means that a single thread can only do code in a specific order, hence it being sequential. The other thing is concurrent code, multiple threads may access the same code synchronously. The programming needs special care put in to it, as multi-threading can pose security risks and inconsistency risks.

Title: What is sequential code execution?

Body: I have been looking around on the internet and have not found a good answer yet.  If anyone could be so kind and supply a code sample I would greatly appreciate it. I apologize for the simplicity of the question.  </p>


问:
Triggering custom events in AJAX callbacks
I'm pretty new to JavaScript, but one of the things that's been frustrating is that our AJAX callbacks have been getting packed with different functionality, making it difficult to keep everything separated and organized.

I'm really new to programming, I have a feeling learning MVC a bit more would help me, but for now using custom events seems like it could help me keep my code a lot cleaner and prevent some problems. Here's what I'm talking about:

```<code>function myAjaxFunctionThatGetsTestData(){
    $.post('ajax/test.html', function(data) {
        $(document).trigger('testDataLoaded',data);
    });
}

function myOtherFunctionThatsDependentUponAjax(){
    getSomeTestData(); //start process of retrieving the data from ajax
    //then let me know when data has been retrieved
    $(document).one('testDataLoaded', function(data){
        alert (data);
    }
}

function getSomeTestData(){
    //maybe data was already retrieved by a different module, so check first
    if (data){
        $(document).trigger('testDataLoaded',data);
    }
    else{
        myAjaxFunctionThatGetsTestData();
    }
}
</code>```

I also don't know if it's ok that I'm triggering document or not...

Are there any patterns that look like this that I can read more about? What are the potential problems with this?

答:
Ideally you want to attach your event handlers to what they relate. In bigger application it can be a dispatcher object or an object that handles communication between javascript objects.

In more simple case, like bind specific UI elements you can simply bind it to them, that way when you set it or trigger it you know the element to with it relates. Or a root element if the UI element is part of a widget.

Otherwise I don't think there is any issue with using the document element as such, maybe it's better to use the triggerHandler() instead depends if you just want to trigger a function or emit a full event object.


答:
Interfaces - The buttons and the volume tuner from the 90's on a TV - the part you use for interaction. You can change or the fix the internals of your TV when it breaks after the 2 year warranty is over while leaving the interface intact.

Constructor - A special method that gets called every time the object instance from a class is created (If you're explaining interfaces to him(?) than he propably knows what an object and a class is).


答:
I think you had a narrow escape, the interviewer didn't really know what he was talking about. Even worse, he believes there is a "right" answer. If he was someone you would want to work for, I'd expect him to take your initial answer, find out why you chose it, and then challenge you to make it better if he can find problems with it.

LINQ scares people because it looks like magic. It's actually very simple (So simple you would need to be a genius to come up with it)

```<code>var result = from item in collection where item=>item.Property > 3 select item;
</code>```

Is compiled into:

```<code>IEnumerable<itemType> result = collection.Where(item=>item.property >3);
</code>```

(Please don't shout if I've got the syntax wrong on either, it's after midnight and I'm in bed :) )

Where is an extension method on IEnumerable which takes a lambda. The lambda is simply (in this case) compiled to a delegate:

```<code>bool AMethod(ItemType item)
{
    return item.property >3;
}
</code>```

The Where method simply adds ALL instances of item where AMethod returns true to a collection which is returned.

There is no reason that would be slower than doing a foreach and adding all matching items to a collection in that loop. In fact the Where extension method is probably doing just that. The real magic comes when you need to inject an alternative where criteria.

As I mentioned above in my comment, some of the examples linked to are very wrong. And it's this sort of misinformation that causes the problems.

Finally, if the interview had of given you a chance, you could have said that:

LINQ is easy to read, especially where you start introducing interesting projections and groupings. Easy to read code is eas[y|ier] to maintain code which is a win.

It would be really easy to measure the performance if it was actually a bottleneck and replace it with something else.

Title: Does LINQ require significantly more processing cycles and memory than lower-level data iteration techniques?

Body:
Background

I am recently in the process of enduring grueling tech interviews for positions that use the .NET stack, some of which include silly questions like this one, and some questions that are more valid.  I recently came across an issue that may be valid but I want to check with the community here to be sure.

When asked by an interviewer how I would count the frequency of words in a text document and rank the results, I answered that I would

Use a stream object put the text file in memory as a string.

Split the string into an array on spaces while ignoring punctuation.

Use LINQ against the array to .GroupBy() and .Count(), then OrderBy() said count.

I got this answer wrong for two reasons:

Streaming an entire text file into memory could be disasterous.  What if it was an entire encyclopedia?  Instead I should stream one block at a time and begin building a hash table.

LINQ is too expensive and requires too many processing cycles.  I should have built a hash table instead and, for each iteration, only added a word to the hash table if it didn't otherwise exist and then increment it's count.

The first reason seems, well, reasonable.  But the second gives me more pause.  I thought that one of the selling points of LINQ is that it simply abstracts away lower-level operations like hash tables but that, under the veil, it is still the same implementation.

Question

Aside from a few additional processing cycles to call any abstracted methods, does LINQ require significantly more processing cycles to accomplish a given data iteration task than a lower-level task (such as building a hash table) would?

Body:
I think you had a narrow escape, the interviewer didn't really know what he was talking about. Even worse, he believes there is a "right" answer. If he was someone you would want to work for, I'd expect him to take your initial answer, find out why you chose it, and then challenge you to make it better if he can find problems with it.

LINQ scares people because it looks like magic. It's actually very simple (So simple you would need to be a genius to come up with it)

var result = from item in collection where item=>item.Property > 3 select item;

Is compiled into:

IEnumerable<itemType> result = collection.Where(item=>item.property >3);

(Please don't shout if I've got the syntax wrong on either, it's after midnight and I'm in bed :) )

Where is an extension method on IEnumerable which takes a lambda. The lambda is simply (in this case) compiled to a delegate:

bool AMethod(ItemType item)
{
    return item.property >3;
}

The Where method simply adds ALL instances of item where AMethod returns true to a collection which is returned.

There is no reason that would be slower than doing a foreach and adding all matching items to a collection in that loop. In fact the Where extension method is probably doing just that. The real magic comes when you need to inject an alternative where criteria.

As I mentioned above in my comment, some of the examples linked to are very wrong. And it's this sort of misinformation that causes the problems.

Finally, if the interview had of given you a chance, you could have said that:

LINQ is easy to read, especially where you start introducing interesting projections and groupings. Easy to read code is eas[y|ier] to maintain code which is a win.

It would be really easy to measure the performance if it was actually a bottleneck and replace it with something else.


答: What people in the United States commonly call a line, as in the thing you stand in at the post office, people in other English speaking countries call a queue.  So, it's easier for Americans to keep the terminology straight if you substitute "line" for "queue."  In other words, when you are in the head, or front, of the line, you are the next to be called.</p>

Title: On a queue, which end is the "head"?

Body:
I had always thought that the "head" of a queue as the next element to be read, and never really questioned that usage. So a linked-list library I wrote, which is used for maintaining queues, codified that terminology: we have a list1_head macro that retrieves the first element; when using this library in a queue, this will be the first element to be removed.

But a new developer on the team was used to having queues implemented the other way around. He described a queue as behaving like a dog: you insert at the head, and remove at the tail. This is a clever enough description that I feel like his usage must be more widespread, and I don't have a similarly evocative description of my preferred usage.

So, I guess, there are two related questions: 1, what does the "head" of a queue mean to you? and 2, why do we use the word "head" to describe that concept?


问:
Lazy Processing of Streams
I have the following problem scenario:

I have a text file and I have to read it and split it into lines.

Some lines might need to be dropped (according to criteria that are not fixed).

The lines that are not dropped must be parsed into some predefined records.

Records that are not valid must be dropped.

Duplicate records may exist and, in such a case, they are consecutive. If duplicate / multiple records exist, only one item should be kept.

The remaining records should be grouped according to the value contained in one field; all records belonging to the same group appear one after another (e.g. AAAABBBBCCDEEEFF and so on).

The records of each group should be numbered (1, 2, 3, 4, ...). For each group the numbering starts from 1.

The records must then be saved somewhere / consumed in the same order as they were produced.

I have to implement this in Java or C++.

My first idea was to define functions / methods like:

One method to get all the lines from the file.

One method to filter out the unwanted lines.

One method to parse the filtered lines into valid records.

One method to remove duplicate records.

One method to group records and number them.

The problem is that the data I am going to read can be too big and might not fit into main memory: so I cannot just construct all these lists and apply my functions one after the other.

On the other hand, I think I do not need to fit all the data in main memory at once because once a record has been consumed all its underlying data (basically the lines of text between the previous record and the current record, and the record itself) can be disposed of.

With the little knowledge I have of Haskell I have immediately thought about some kind of lazy evaluation, in which instead of applying functions to lists that have been completely computed, I have different streams of data that are built on top of each other and, at each moment, only the needed portion of each stream is materialized in main memory.

But I have to implement this in Java or C++. So my question is which design pattern or other technique can allow me to implement this lazy processing of streams in one of these languages.

答:
You should look into iterators if deciding for Java.

Write an Iterator<String> that reads a line from the file.  Write a filtering iterator that accepts the above iterator in the constructor and only generate those lines you are interested in.  Write a splitting Iterator<Record> that accepts a string iterator in the constructor, and splits each line into a record.  And so on.

You will most likely find that you will do the processing in the "are there more?" section to get the logic right.

Title: Lazy Processing of Streams


问:
Git: Pushing to a remote repo from a remote repo?
I have a destination repo that is remote and I have a source repo
that is also remote. I would like my local machine to act as a proxy
to allow me to push to the destination from the source without ever
download the repo to my machine. Is this possible?</p>

答:
You need to launch the push command on the source remote.

You can make that through:

a direct ssh session

or a script called through an authorization layer like Gitolite through ssh.

See ADC (Admin Defined Commands)

The admin-defined commands (ADCs) feature allows controlled access to specific, "safe", programs or scripts, without giving users full shell access.


问:
What does "enterprise" means in relation to software architecture?
I see the term "enterprise" being thrown around software developers and programmers a lot and used loosely it seems.

en·ter·prise/ˈentərˌprīz/

Noun: A project or undertaking, typically one that is difficult or requires effort.
Initiative and resourcefulness.

Can someone please clarify what this term actually encompasses? "At an enterprise level", "enterprise scale"? There are even "enterprise editions" of things. What exactly does it mean? It obviously doesn't make sense judging by the above definition so more specifically to software what does one mean when using the word enterprise?

EDIT:

To add a spin on this - how does this term then fit into phrases such as Enterprise Framework Model? What does data access and data context have to do with company-wide descriptions?

答:
Enterprise software typically is:

Internal facing;

Either mission critical and/or used by many people throughout the business; and

Integrated with other internal and/or external facing systems

Enterprise software doesn't necessarily have to be implemented in a large company.  An example might be an electronic medical record system at a small doctor's office that is integrated with hospital lab systems and insurance claims processing systems.


问:
Any success stories about using slicing tools to help debugging
Program slicing is one of those software technologies where there is much more activity in the research community than in the industry community. Does anybody outside of the research community using slicing tools on production code to help with debugging or other tasks? If so, what tools did you use?</p>

答:
An online XPath Tracer performs slicing, but it might not meet your definition because it's for an expression language, XPath 2.0, rather than a full-blown programming language.

Currently, this permits specific parts of the expression to be selected; the 'path' for that part of the expression is then resolved and displayed. In this case, XSLT 2.0 is being used to perform a partial parse of the expression.

This tracer has 2 objectives for when it's complete:

It will allow an auto-complete list to show available nodes for a
specific path (for a chosen source file) - when a part of the expression is being edited.

When an expression doesn't behave as expected, different expression
parts can be evaluated to narrow down the area of interest.


答:
This is jquery probably, which unfortunately changes the way you write code to more php-ish like.

Normally when using mootools i'd pack the call and handlers into an object. For example.

```<code>function edit_handler(a,b,c)
{

    var that = this; //priv member
    this.onProcess = function(data) {}; //public member
    this.onOk = function() {};
    this.onFailure = function() {};

    function process(data) // priv method
    {
        that.onProcess();
        //do processing
    }

    this.run = function (param) //public method
    {
        AJAX.call => onSuccess => process(ret) ; onFail => that.onFailure();
    }

}

var edit_amount = new edit_handler(1,2,3);
edit_amount.onFailure = function() {alert("Update failed");}
form field=> on edit => edit_amount.process(value);
</code>```

My point - use objects and private methods / properties. Making many functions is always creating a mess.

Title: Triggering custom events in AJAX callbacks

Body:
I'm pretty new to JavaScript, but one of the things that's been frustrating is that our AJAX callbacks have been getting packed with different functionality, making it difficult to keep everything separated and organized.

I'm really new to programming, I have a feeling learning MVC a bit more would help me, but for now using custom events seems like it could help me keep my code a lot cleaner and prevent some problems. Here's what I'm talking about:

```<code>function myAjaxFunctionThatGetsTestData(){
    $.post('ajax/test.html', function(data) {
        $(document).trigger('testDataLoaded',data);
    });
}

function myOtherFunctionThatsDependentUponAjax(){
    getSomeTestData(); //start process of retrieving the data from ajax
    //then let me know when data has been retrieved
    $(document).one('testDataLoaded', function(data){
        alert (data);
    }
}

function getSomeTestData(){
    //maybe data was already retrieved by a different module, so check first
    if (data){
        $(document).trigger('testDataLoaded',data);
    }
    else{
        myAjaxFunctionThatGetsTestData();
    }
}
</code>```

I also don't know if it's ok that I'm triggering document or not...

Are there any patterns that look like this that I can read more about? What are the potential problems with this?

Body:
This is jquery probably, which unfortunately changes the way you write code to more php-ish like.

Normally when using mootools i'd pack the call and handlers into an object. For example.

function edit_handler(a,b,c)
{

    var that = this; //priv member
    this.onProcess = function(data) {}; //public member
    this.onOk = function() {};
    this.onFailure = function() {};

    function process(data) // priv method
    {
        that.onProcess();
        //do processing
    }

    this.run = function (param) //public method
    {
        AJAX.call => onSuccess => process(ret) ; onFail => that.onFailure();
    }

}

var edit_amount = new edit_handler(1,2,3);
edit_amount.onFailure = function() {alert("Update failed");}
form field=> on edit => edit_amount.process(value);

My point - use objects and private methods / properties. Making many functions is always creating a mess.


问:
Would this violate any copyright issues?
I am currently publishing a paper on skin detection. However, I need to find the appropriate histogram bin size for each colorspace. I recently came upon a paper that published what it found to be the ideal bin size. The paper can be found at: http://www.inf.pucrs.br/~pinho/CG/Trabalhos/DetectaPele/Artigos/OPTIMUM%20COLOR%20SPACES%20FOR%20SKIN%20DETECTION.pdf. I am specifically talking about Table 1. If I cite the source, would it be okay for me to use data from the table?

Note that I cannot contact the author of the paper.

答:
Yes using the data would be perfectly normal

But I'm not a lawyer, I'm only an academic talking about the etiquette of quoting results from another academic paper, I can't say anything about the copyright law in Azerbijan when applied to web apps by a Liberian shell company registered in the Cayman islands.


问:
Which stages of the requirements analysis process in mobile requirements engineering are the most challenging ones?
I'm doing a research on formulating a requirements analysis model as a stage  of requirements engineering for mobile-application development by considering the limitations and the needs of it ( agility and etc.. .), what I'm trying to figure out is that which parts of this process (requirements analysis for mobile development) are the most challenging ones ( so i can focus more on) , and if there is any stage that u think I need to include or exclude (exp. some may think a quality plan may or may not be necessary and etc.)

to make it more clear below is the list of few of the areas in which I can focus on ( by the way your suggestions can be anything out of the below list.)

-Requirements specification
-Prototyping
-Requirements Prioritization
-Focusing on quality functions

答:
Horizontal traceability of functional requirements.

Vertical traceability, from parent requirement to child requirement, has long been considered an important part of requirements analysis.  Horizontal traceability is a new concept that has only recently become feasible.

Functional requirements take input data, do some kind of processing, and produce an output data item.  If there are no missing requirements, all of the system outputs can be traced back through a series of requirements, to the system inputs.

The "trace" is done by noting that every input data item must be the output of some other requirement. Thus the requirements are horizontally connected, input to output. Missing connections mean missing requirements.

Verifying the horizontal traceability of more than a handful of requirements "by hand" is simply infeasible. Using a spreadsheet macro to do the analysis makes it possible to easily find most of the missing requirements.

It is very new and not well known. I wrote an Excel macro to partialy automate the process. It is available for free at http://www.barbarabea.com/?page_id=11

There is also a tutorial and user guide.

I have used it on a few projects. One of the projects had a mature set of requirements, i.e. a product based on those requirements had been completed and shipped. When those reqs were put in the spreadsheet we found that there were a lot of reqs missing. (~40%) Another project used it to write new functional requirements. For the new reqs, the graphical output was the most important part. Seeing how all the reqs tied together helped identify which reqs should be written next and which needed to be modified because they did not fit well with the rest.

I do have another idea. But it is more academic than practical. It is also written up at the Barbara Bea blog.

One of the characteristics of a good requirement, we are told, is that it is unambiguous. This is usually defined as having only one possible interpretaion. Any high level requirement that has child requirements is ambiguous. Otherwise it would not need child requirements.

But how do you go about deciding whether or not a requirement is ambiguous? I have created an objective test to determine if a functional requirement is ambiguous. If you start with a set of functional requirements that are horizontally connected, then each functional requirement is unambiguous if, and only if, the processing step is an algorithm.

Told you it was academic. But it is also the only objective test for ambiguity that I have ever seen.


问:
Is it possible to efficiently store all possible phone numbers in memory?
Given the standard North American phone number format: (Area Code) Exchange - Subscriber, the set of possible numbers is about 6 billion. However, efficiently breaking down the nodes into the sections listed above would yield less than 12000 distinct nodes that can be arranged in groupings to get all the possible numbers.

This seems like a problem already solved.

Would it done via a graph or tree?

答:
Graph isn't suitable for this, the implementation requires more memory than tree and it doesn't provide any additional features in this case.

Prefix trees? These are very efficient for search but memory representation isn't optimized for size. They're in fact very memory inefficient. They can also be used to compress data and write it to disk but memory representation takes much more memory than the data itself.

If you arrange by groups so only 3 last digits would be stored in the tree-like struct it'd be 3x4 + 1 bytes for each number anyway (3x4 byte pointer + 1 byte for data). ~78 GB just for 3 last digits of each number (if i remember the implementation details correctly). Which will require 64 bit pointers instead of 32b... so ~140GB of ram.

So the problem (in my opinion) is that for tree for each suffix in each group you still need at least one 32 bit pointer (which will probably turn out to be 64 bits because you'd need to allocate > 4GB for the data).

In my opinion most efficient way will be an array or 12000 pointers to structure like

```<code>char[x] prefix;
DWORD* suffixes;
int n_count;
</code>```

so prefix, eg. 43333 suffix eg. 19821982 => number is 4333319821982 (n_count -> count of numbers)

You store the numbers without separators to save space, one suffix after the other (eg. number 1 is suffixes+0, number 2 is suffixes+1) and you can search efficiently too, if you have it sorted.

This way it'd take just 4(DWORD)*6 billion suffixes = 24GB of memory + size of 12k pointers + prefixes which is irrelevant

So instead of (at least!) 6 billion 64 bit pointers you'd just have (at most!) 6b of 32 bit suffixes.

But probably the numbers are continuous, so you can try array of (start_suffix, end_suffix) instead of just storing all suffixes should take much less.

Body:
Graph isn't suitable for this, the implementation requires more memory than tree and it doesn't provide any additional features in this case.

Prefix trees? These are very efficient for search but memory representation isn't optimized for size. They're in fact very memory inefficient. They can also be used to compress data and write it to disk but memory representation takes much more memory than the data itself.

If you arrange by groups so only 3 last digits would be stored in the tree-like struct it'd be 3x4 + 1 bytes for each number anyway (3x4 byte pointer + 1 byte for data). ~78 GB just for 3 last digits of each number (if i remember the implementation details correctly). Which will require 64 bit pointers instead of 32b... so ~140GB of ram.

So the problem (in my opinion) is that for tree for each suffix in each group you still need at least one 32 bit pointer (which will probably turn out to be 64 bits because you'd need to allocate > 4GB for the data).

In my opinion most efficient way will be an array or 12000 pointers to structure like

char[x] prefix;
DWORD* suffixes;
int n_count;

so prefix, eg. 43333 suffix eg. 19821982 => number is 4333319821982 (n_count -> count of numbers)

You store the numbers without separators to save space, one suffix after the other (eg. number 1 is suffixes+0, number 2 is suffixes+1) and you can search efficiently too, if you have it sorted.

This way it'd take just 4(DWORD)*6 billion suffixes = 24GB of memory + size of 12k pointers + prefixes which is irrelevant

So instead of (at least!) 6 billion 64 bit pointers you'd just have (at most!) 6b of 32 bit suffixes.

But probably the numbers are continuous, so you can try array of (start_suffix, end_suffix) instead of just storing all suffixes should take much less.


问:
What is the preferred Internet media type of a RESTful POST request?
Is there a preferred/recommended Internet Media Type for RESTful POST requests?

For example, if I want to add a new user, should I send the data as a URL encoded string like:

```<code>name=Foo&otherData=Bar
</code>```

or does REST recommend I send the data as whatever format the response is going to be sent as (e.g. JSON/XML)?

```<code><user>
  <name>Foo</name>
  <other-data>Bar</other-data>
</user>
</code>```

答: Typically web services support both XML and JSON based on the user's preference. A lot of people tend to use JSON because it usually allow you to send the same data in a more compact way, which is important for web services(especially if they have mobile clients).</p>


答:
The definitions are fine and good.  In software this seems to be attached as a marketing term- a code word that says "buy this for your business, this is serious software where you can get support."  Whether or not that's true depends on the product, but that's the message marketing is trying to send.  The support part of that is important for many businesses- they want someone on the other end of the phone when they call with a problem.

In this context, it's a marketing term.

Title: What does "enterprise" means in relation to software architecture?

Body:
I see the term "enterprise" being thrown around software developers and programmers a lot and used loosely it seems.

en·ter·prise/ˈentərˌprīz/

Noun: A project or undertaking, typically one that is difficult or requires effort.
Initiative and resourcefulness.

Can someone please clarify what this term actually encompasses? "At an enterprise level", "enterprise scale"? There are even "enterprise editions" of things. What exactly does it mean? It obviously doesn't make sense judging by the above definition so more specifically to software what does one mean when using the word enterprise?

EDIT:

To add a spin on this - how does this term then fit into phrases such as Enterprise Framework Model? What does data access and data context have to do with company-wide descriptions?


答:
If you were doing this for ultimate memory efficency you could do better.

Start with the area code - I don't know how many are actually used but assuming you need to store all 3 digit values.

Presumably exchange codes are filled in order, so you would expect the lower ones to be used in more areas than the higher ones. So you could use a run-length coding to flag the sequences that are in use.

Finally actual phone numbers will be used or not at random so I would use a bit field to flag which of the 9999 possible last numbers are on. At one bit/number you need only 1K to store each set.

Title: Is it possible to efficiently store all possible phone numbers in memory?

Body:
Given the standard North American phone number format: (Area Code) Exchange - Subscriber, the set of possible numbers is about 6 billion. However, efficiently breaking down the nodes into the sections listed above would yield less than 12000 distinct nodes that can be arranged in groupings to get all the possible numbers.

This seems like a problem already solved.

Would it done via a graph or tree?


问:
Pros and cons of hosted scripts
I have seen some developers use hosted scripts to link their libraries.

cdn.jquerytools.org is one example.

I have also seen people complain that a hosted script link has been hijacked.

How safe is using hosted scripts in reality?  Are the scripts automatically updated? For example, if jQuery 5 goes to 6 do I automatically get version 6 or do I need to update my link?

I also see that Google has a large set of these scripts setup for hosting.

What are the pros and cons?

答: Something no one mentioned is yet another tracking option for Google. They're not offering all these services at no cost for no reason. AdSense and Analytics are quite enough and at least those can be filtered. That's a big con in my book.</p>

Title: Pros and cons of hosted scripts


答: If my calculations are correct, a bit array for each phone number should take about 1.2 GB of memory. Simply set the bit for each phone number that is valid. </p>


答:
A comment you placed on the question:

It was an easier question to ask, instead of qualifying. Let's just
  say that there are much more than 5, but still less than 6 billion.
  :-)

So it sounds like you intend to store all current valid phone numbers, in the range of (000) 000-0000 through (999) 999-9999.  So the set of possible numbers is 10,000,000,000, or, 10 billion.

This number can immediately be reduced to less than 8 billion, since the first digit in an area code cannot be a 0 or 1, area code cannot end in "11", and 555 numbers are reserved, as well as a few other rules.

Since only a maximum of 8 billion are available, and you mention storing 5-6 billion, I propose the much more space-efficient storage of the 2-3 billion unused numbers.

To generate a list of valid numbers, you would then numerically loop through all combinations, and skip numbers in the list of invalid numbers.  Or, simply check to see that a number is not in the store invalid numbers, to know if it is valid.

A Trie tree or a Radix tree are most likely going to be the most space efficient while still having fast lookup/insert/remove speeds.


问:
Why were frames removed in HTML5, but not iFrames?
Why were frames removed in HTML5, but not iFrames? After all, there is almost no difference between the two. In many instances using either of them would give the same output (pardon me if I am wrong)?</p>

答:
There's a couple of misconceptions in your post. First, the frame and frameset elements are not deprecated in HTML5, they're obsolete (i.e., they've been removed entirely).

Second, the frame and frameset elements are not the same thing as the iframe element, nor do they give the same output:

The frameset element replaces the body element in pages as a means to include a different document model for web pages: they're bad for usability and accessibility, and what they intended to accomplish have been completely replaced by CSS and ubiquitous server-side development.

The iframe element, on the other hand, does not replace the body of a page. It acts as a means to include a new browsing context embedded within a block of content. It does not suffer from the same usability or accessibility problems as the frameset model and is used almost anywhere one needs to include an embedded browsing context (widgets being the most prolific example).1

The iframe in HTML5 also takes on additional features in that it can be sandboxed, allowing the parent document to decide what gets executed within it. This allows for some measure of security for the parent document (and visitors to the parent document) when embedding untrusted content.

Notes

Note 1: the object element somewhat overlaps with the iframe element, but it has a different content model (which is intended mainly for plugins), has its own set of caveats, and doesn't have the sandboxing attributes the iframe element has.


答:
Frames (frameset) acts as document. It's removed because it breaks HTML documents structure and navigation. Eg. you have links in one frame, content in the other, you can't open link from the page in in a new window, you can't link to specific sub-page, etc.

On the other hand iframes won't break anything if used correctly because they're meant to sandbox content (eg. ads).

Body: Why were frames removed in HTML5, but not iFrames? After all, there is almost no difference between the two. In many instances using either of them would give the same output (pardon me if I am wrong)?</p>


问:
Subversion server hierarchy, need advice
I have a subversion server setup that I need to look after several projects, grouped by language, then client (company) and then by project

e.g.

```<code>repos/

flex3
     \com1
          \project1
          \project2
     \com2
          \project1
          \project2
          \project3

flex4
     \com1
         \projectx
     \com2
         \projecty

java
    \projectz
</code>```

repos is my repository root and then I have the 3 repositories inside (create with svnadmin create) flex3, flex4 and java, then flex3 should have two folders com1 and com2 for different clients, each will contain different "project" repos.

I have a feeling I have done this wrong, should I simply create the top level structure as normal folders and then make the com1 and com2 etc into repos with "svnadmin create" so that different projects can be added directly below them. Is this correct?

Thanks

答:
I think you should ask yourself following questions before deciding repository layout for your company.

What data do you expect to live in your repository (or repositories), and
  how will that data be organized?

Where will your repository live, and how will it be accessed?

What types of access control and repository event reporting do you
  need?

Which of the available types of data store do you want to use?

Here you will find full article and how to answer above queries...

We have been using Visual SVN Server for quiet time to manage our project repositories.
Have a look at Visual SVN Server recommended repository layout

Said that, we are not using Visual SVN recommended layout; because we have projects which may overlap technologies e.g. an ASP.NET project may have flash module or ASP admin (for some legacy applications). And there is access restriction each projects.

This is what we are using, and it seems to be working fine so far. Some tasks are very easy, especially repo backup routines, access management and trunk, branch and tag structure.

```<code>+ Repositories (root)
    + Project 1 (repository)
    + .......
    + Project 2 (repository)
    + .......
    + Project 3 (repository)
    + .......
</code>```

ContentLicense: CC BY-SA 2.5

Body:
I think you should ask yourself following questions before deciding repository layout for your company.

What data do you expect to live in your repository (or repositories), and
  how will that data be organized?

Where will your repository live, and how will it be accessed?

What types of access control and repository event reporting do you
  need?

Which of the available types of data store do you want to use?

Here you will find full article and how to answer above queries...

We have been using Visual SVN Server for quiet time to manage our project repositories.
Have a look at Visual SVN Server recommended repository layout

Said that, we are not using Visual SVN recommended layout; because we have projects which may overlap technologies e.g. an ASP.NET project may have flash module or ASP admin (for some legacy applications). And there is access restriction each projects.

This is what we are using, and it seems to be working fine so far. Some tasks are very easy, especially repo backup routines, access management and trunk, branch and tag structure.

+ Repositories (root)
    + Project 1 (repository)
    + .......
    + Project 2 (repository)
    + .......
    + Project 3 (repository)
    + .......


答:
The following Chrome screenshot shows the trace output from an XSLT 2.0 processor running in the browser:

The XSLT program is 'sliced' so every instruction records in the trace output when it was executed. The nesting of the output XML explains the execution hierarchy.

The above sample helps show the actual template that was executed as a result of the xsl:apply-templates instruction. Thus the trace shows the same information that you would get from an IDE debugger - but without having to step through each line of code.

If an exception is thrown within the executing code, then the trace terminates at that point, showing exactly where the code failed, providing more information that a typical call-stack.

Also, additional trace instructions can be embedded in the XSLT (in the form of a fn:trace function call) to provide extra diagnostics for a specific part of the code.

Title: Any success stories about using slicing tools to help debugging

Body: Program slicing is one of those software technologies where there is much more activity in the research community than in the industry community. Does anybody outside of the research community using slicing tools on production code to help with debugging or other tasks? If so, what tools did you use?</p>


问:
Teacher demands excessive/unjustified use of Design Patterns
I study computer science and I have a class called "Programming Techniques". Its purpose is to teach (us) good object oriented design principles. During the semester we have homeworks, programs that we must write to demonstrate what we've learned.

The lab assistant demands for each of these homeworks that specific design patterns should be used. For example, the current homework is an application used for processing customer orders. We are demanded to use either "Factory Method" or "Abstract Factory" design patterns for this. It gets even worse: at the end of the semester we must write a program (something more complex) that must use at least one creational pattern, at least one structural pattern and at least one behavioural pattern.

Is it normal to demand this ? I mean, forcing us to design our programs in such a way that a specific design pattern makes sense is just beyond what I consider ok. If I'm a car mechanic and have a huge tool box, then I will use a certain tool from that box if and when the situation demands it. Not more, not less. If my design of the application doesn't demand at all the use of "Abstract Factory" (for example), then why should I implement it ?

I'm not sure yet if the senior lecturer agrees with what the lab assistant is demanding, but I want to talk to him about it and I need solid arguments to do so. How should I approach this problem with him ?

PS: I'm sure there must be a better way to teach us these things. Maybe making us each week read about 3 design patterns and the next week giving us a test with small but specific programming or architectural situations/problems. The goal in that test would be to identify what design patterns would make sense and how they could be implemented. This way, he can see if we understand them.

EDIT: These homeworks are not just 100-line programs, they have quite a lot of requirements and are fairly complicated. This is the reason we have about 2 - 3 weeks of deadline for each of them.

I agree that practicing this is the best way to learn. But shouldn't smaller programs/applications be used for this ? Something just for demonstrating purposes. Not big programs with lots of requirements/classes/etc.

答: You are in university? I hardly see the problem. I'm finishing my last year of high school and my CS teacher has always given us these kind of assignments throughout the whole semester each year I took his course. Even now, he gave us 2 weeks to finish an oop assignment, something I'm working with for the first time. Just like in your case, it's not a 100 line program but don't guage difficulty based on lines of code. Sometimes it's outright a difficult task, other times it's poor efficiency. Don't get me wrong, I was clueless and miserable the first week in but once I understood the very fundamentals, branching out to evolve the fundamental requirements became very rewarding. Your teacher is not giving you the best tools because that is one of the things that completely kill creativity and understanding. Why bother error checking with switch or if statements when you can simply use try-catch blocks? Why should you parse through a list component variable by variable instead of using a function which does it for you? The answer you're looking for won't always be the easiest of ways, but it will only get easier when you understand when and why to use the tools given to you. </p>


答:
One skill you need to learn in order to survive school, work, and even in life, is to learn to pick your battles. In this case, unless the people giving the course are either breaking the law, or otherwise behaving in an unethical manner, then there usually isn't much you can do about these things. It isn't even a case of whether you are right or not. You need to learn when to question, then when to either question further, or to simply go with the flow.

University is really a means to an end. It's a few years of learning how to cope with stress and how to educate yourself. In IT, you are rarely being taught much in your lectures that will last you more than a few years, and by the time you leave school, the only real skills you will have will be to deal with stress, meet deadlines, and most importantly about how to further your education on your own while you work.

While I realize this doesn't specifically satisfy your question, my advice is to simply play along.  By the end of it all, you will either have learned to accept what you have been taught, or you will have learned to learn from multiple sources and to make up your own mind in the end.  Either way, you'll save yourself a lot of stress if you simply get the work done, and then move beyond it.  This in itself is a very useful social skill to learn when you find yourself with a potentially disagreeable boss and a job that isn't being dove the way you would do it yourself.

Title: Teacher demands excessive/unjustified use of Design Patterns

Body:
I study computer science and I have a class called "Programming Techniques". Its purpose is to teach (us) good object oriented design principles. During the semester we have homeworks, programs that we must write to demonstrate what we've learned.

The lab assistant demands for each of these homeworks that specific design patterns should be used. For example, the current homework is an application used for processing customer orders. We are demanded to use either "Factory Method" or "Abstract Factory" design patterns for this. It gets even worse: at the end of the semester we must write a program (something more complex) that must use at least one creational pattern, at least one structural pattern and at least one behavioural pattern.

Is it normal to demand this ? I mean, forcing us to design our programs in such a way that a specific design pattern makes sense is just beyond what I consider ok. If I'm a car mechanic and have a huge tool box, then I will use a certain tool from that box if and when the situation demands it. Not more, not less. If my design of the application doesn't demand at all the use of "Abstract Factory" (for example), then why should I implement it ?

I'm not sure yet if the senior lecturer agrees with what the lab assistant is demanding, but I want to talk to him about it and I need solid arguments to do so. How should I approach this problem with him ?

PS: I'm sure there must be a better way to teach us these things. Maybe making us each week read about 3 design patterns and the next week giving us a test with small but specific programming or architectural situations/problems. The goal in that test would be to identify what design patterns would make sense and how they could be implemented. This way, he can see if we understand them.

EDIT: These homeworks are not just 100-line programs, they have quite a lot of requirements and are fairly complicated. This is the reason we have about 2 - 3 weeks of deadline for each of them.

I agree that practicing this is the best way to learn. But shouldn't smaller programs/applications be used for this ? Something just for demonstrating purposes. Not big programs with lots of requirements/classes/etc.


问:
Is it right to appraise Scrum members according to number of successful user stories completed?
When my Manager told to team that "from now on successful user stories will be considered for appraisal!"

We sat there for while shocked and that was one of the several jaw dropping moments he gave us.

We felt that was stupid idea, since this will ruin all concept and goal of agile development methodology.

Let me know what you people think? And how can we convince him?

答:
I agree with ChrisF that this goes back to the same problem with any measurement.  What you praise is what you get.  There are always going to be people that game the system, whatever that system is going to be.

The only real effective method that I've found for rewarding programmer's comes with three steps.

Leads know and understand the abilities of the people on their team.

Managers listen to the recommendations of the leads for team members who aren't pulling their weight.

The team is praised as a whole for successful sprints.

The entire key is that programmer's are not cogs in a machine that can be 'tuned' by looking at statistics.  The real people need to be examined and improved as whole and the team needs to be able to rely on each other in a cooperative, and not a competitive manner.

The poor performers on the team are given every opportunity for improvement and enrichment before they are considered to be let go.  Ultimately, good programmers will thrive in this environment and the poor programmers, who refuse to be improved, will be let go.


问:
Possible applications of algorithm devised for differentiating between structured vs random text
I have written a program that can rapidly (within 5 sec on a 2GB RAM desktop, 2.33 Ghz CPU) differentiate between structured text (e.g English text) and random alphanumeric strings. It can also provide a probability score for the prediction.

Are there any practical applications/uses of such a program? Note that the program is based on entropy models and does not have any dictionary comparisons in its workflow.

答:
You could "reverse" the algorithm, to generate natural-looking phrases. This could be used in games to generate the text on signs and posters, newspapers on the floor, etc. in a procedurally generated world. The text would look intelligible, but still look like natural language.

If I understand your algorithm correctly, you do some kind of measure on entropy, so it won't accurately model which letters should be used by the text. If that is the case, a simple tweak to generate likely alternations of vowels and consonants, like proposed here : http://www.umbrarumregnum.net/articles/creating-names.


问:
How important are UML diagrams for a successful project?
I'm in the middle of a project and I was asked to write UML diagrams (use cases,class diagram,etc). The project isn't very complex.

I was wondering if this be a waste of my time? Should I just be doing other fun stuff like writing code? And when is it not ok to build something without going through all of the conceptual phase? Is it all about complexity? And if so, how to measure it?

答:
Planning is critical, but as the famous strategist Carl von Clausewitz warns

No campaign plan survives first contact with the enemy

So its not a huge waste of time for planning how to initially attack the problems. But likely a waste of time for documenting your code for future programmers. To use a military metaphor, you need a battle plan, but you wouldn't give that plan to historians to use as an after action report.

More concretely, you can use these diagrams to communicate your intentions amongst your team and think about your plan of attack before and during the project. But odds are that what you come up with will need to be tweaked as you code and learn more about the problem. Almost always your initial plan/design needs to be altered because you can't know everything up front.


答:
Project work documentation is a fundamental deliverable of a professional project. How much is enough? Well it depends of course on many factors. However, in my opinion, use cases, class diagrams, process flow diagrams, etc. are not waste of time at all. They have value in various project phases. The only problem with documentation is usually resources.

Some programmers consider documentation is a waste of time. But this is not true. If you view documentation as a display of your design and system rules in an elegant and clear way, you may come to appreciate it more. Also, one needs to put one's self in the position of the people that need to maintain the system. To be thrown 500 files of code and to be asked to fix the problems with them is kind of bad but not uncommon.

I suggest you allocate time in your project and produce the diagrams in cycles. The first would cover the high level aspects of your project and subsequent levels could dwell more on the details.

Use cases in particular can't be deduced easily from code (unlike many other aspects of a system). Make sure you do those.

Title: How important are UML diagrams for a successful project?

Body:
I'm in the middle of a project and I was asked to write UML diagrams (use cases,class diagram,etc). The project isn't very complex.

I was wondering if this be a waste of my time? Should I just be doing other fun stuff like writing code? And when is it not ok to build something without going through all of the conceptual phase? Is it all about complexity? And if so, how to measure it?


答:
I use UML (or sth similar to UML :)) when I talk to friends about something we're about to do. To discuss ideas. Not to prepare UML project that will autogenerate code for me. I can't imagine creating my classes in UML then generate code and not tweak it later. This never happens. So you will have to bring changes from code to UML. And when I use UML I draw on whiteboard or paper. Never in tool like Enterprise Architect.

The only reason to document my whole code in UML would be a contract where client demands it. For example when he want's to have an option to change software shop after part of software was finished.


答:
I was a big fan of UML a while ago. I'm even OMG certified. I used it extensively in large enterprise projects I was involved in.

Today, I stopped UML almost completely. Sometimes, I use the sequence diagram that I find very useful to describe interactions between systems, but no other diagrams.

I now prefer working with user stories, supported by both (only) necessary documentation written by product owner (or analysts) AND his (their) dedication to the development team to give more details as needed.

UML is a tool you can use, but it's certainly not a critical factor for the success of your projects. After many years, I now think the critical factor is the development team, no matter which tools it uses.


答:
UML is a tool, nothing more, and whether it is useful or even crucial depends solely on your development and design workflow. There are many ways to Rome, and some of them involve UML, while others don't.

If your workflow relies on UML to document or plan your architecture, then dropping it would be silly. If UML is the best possible way of communicating the project structure to other team members (in the wider sense), then by all means, use it. But if the project works fine without UML, then making UML diagrams just for the sake of it is nonsense.