答:
The Single Responsibility Principle is about your code doing only 1 thing and you can split all functionality in several classes which all are meant for doing 1 specific thing.
An example is a specific class for validation, doing some business logic, enriching a model, retrieving data, updating data, navigation, etc.

The Separation of Concerns is about your code not being tightly coupled to some other classes/systems. Using interfaces in your code helps a lot, this way you can loosly couple classes/systems to you code. A plusside on this is that it's easier to unit-test your code also. There are a lot of (IoC) frameworks which can help you achieve this, but you can implement such a thing yourself also of course.

An example of something SoC, but not having SRP

```<code>public class Foo
{
    private readonly IValidator _validator;
    private readonly IDataRetriever _dataRetriever;

    public Foo(IValidator validator, IDataRetriever dataRetriever)
    {
        _validator = validator;
        _dataRetriever = dataRetriever;
    }

    public NavigationObject GetDataAndNavigateSomewhereIfValid()
    {
        var data = _dataRetriever.GetAllData();

        if(_validator.IsAllDataValid(data))
        {
            object b = null;
            foreach (var item in data.Items)
            {
                b = DoSomeFancyCalculations(item);
            }

            if(_validator.IsBusinessDataValid(b))
            {
                return ValidBusinessLogic();
            }
        }
        return InvalidItems();
    }

    private object DoSomeFancyCalculations(object item)
    {
        return new object();
    }
    private NavigationObject ValidBusinessLogic()
    {
        return new NavigationObject();
    }

    private NavigationObject InvalidItems()
    {
        return new NavigationObject();
    }
}
</code>```

As you can see, this code isn't tightly coupled to classes or other systems, because it only uses some interfaces to do stuff. This is good from a SoC standpoint.

As you can see this class also contains 3 private methods which do some fancy stuff.
From a SRP standpoint, those methods should probably be placed within some classes of their own. 2 of them do something with navigation, which would fit in some INavigation class. The other does some fancy calculations on an item, this could probably be placed within an IBusinessLogic class.

Having something like this, you both have the SoC and SRP in place:

```<code>public class Foo
{
    private readonly IValidator _validator;
    private readonly IDataRetriever _dataRetriever;
    private readonly IBusinessLogic _businessLogic;
    private readonly INavigation _navigation;

    public Foo(IValidator validator, IDataRetriever dataRetriever, IBusinessLogic businessLogic, INavigation navigation)
    {
        _validator = validator;
        _dataRetriever = dataRetriever;
        _businessLogic = businessLogic;
        _navigation = navigation;
    }

    public NavigationObject GetDataAndNavigateSomewhereIfValid()
    {
        var data = _dataRetriever.GetAllData();

        if(_validator.IsAllDataValid(data))
        {
            object b = null;
            foreach (var item in data.Items)
            {
                b = _businessLogic.DoSomeFancyCalculations(item);
            }

            if(_validator.IsBusinessDataValid(b))
            {
                return _navigation.ValidBusinessLogic();
            }
        }
        return _navigation.InvalidItems();
    }
}
</code>```

Of course you could debate if all this logic should be placed in the GetDataAndNavigateSomewhereIfValid method. This is something you should decide for yourself. To me it looks like this method is doing way too much stuff.

Title: What is the difference between Single Responsibility Principle and Separation of Concerns

Body:
a)What is the difference between SRP and SoC? Perhaps that SRP is applied at class level, while SoC can be applied at system, subsystem, module, class or function levels.

b) If answer to a) is yes, is then SoC applied at class level a synonym for SRP?

thank you

Body:
The Single Responsibility Principle is about your code doing only 1 thing and you can split all functionality in several classes which all are meant for doing 1 specific thing.
An example is a specific class for validation, doing some business logic, enriching a model, retrieving data, updating data, navigation, etc.

The Separation of Concerns is about your code not being tightly coupled to some other classes/systems. Using interfaces in your code helps a lot, this way you can loosly couple classes/systems to you code. A plusside on this is that it's easier to unit-test your code also. There are a lot of (IoC) frameworks which can help you achieve this, but you can implement such a thing yourself also of course.

An example of something SoC, but not having SRP

public class Foo
{
    private readonly IValidator _validator;
    private readonly IDataRetriever _dataRetriever;

    public Foo(IValidator validator, IDataRetriever dataRetriever)
    {
        _validator = validator;
        _dataRetriever = dataRetriever;
    }

    public NavigationObject GetDataAndNavigateSomewhereIfValid()
    {
        var data = _dataRetriever.GetAllData();

        if(_validator.IsAllDataValid(data))
        {
            object b = null;
            foreach (var item in data.Items)
            {
                b = DoSomeFancyCalculations(item);
            }

            if(_validator.IsBusinessDataValid(b))
            {
                return ValidBusinessLogic();
            }
        }
        return InvalidItems();
    }

    private object DoSomeFancyCalculations(object item)
    {
        return new object();
    }
    private NavigationObject ValidBusinessLogic()
    {
        return new NavigationObject();
    }

    private NavigationObject InvalidItems()
    {
        return new NavigationObject();
    }
}

As you can see, this code isn't tightly coupled to classes or other systems, because it only uses some interfaces to do stuff. This is good from a SoC standpoint.

As you can see this class also contains 3 private methods which do some fancy stuff.
From a SRP standpoint, those methods should probably be placed within some classes of their own. 2 of them do something with navigation, which would fit in some INavigation class. The other does some fancy calculations on an item, this could probably be placed within an IBusinessLogic class.

Having something like this, you both have the SoC and SRP in place:

public class Foo
{
    private readonly IValidator _validator;
    private readonly IDataRetriever _dataRetriever;
    private readonly IBusinessLogic _businessLogic;
    private readonly INavigation _navigation;

    public Foo(IValidator validator, IDataRetriever dataRetriever, IBusinessLogic businessLogic, INavigation navigation)
    {
        _validator = validator;
        _dataRetriever = dataRetriever;
        _businessLogic = businessLogic;
        _navigation = navigation;
    }

    public NavigationObject GetDataAndNavigateSomewhereIfValid()
    {
        var data = _dataRetriever.GetAllData();

        if(_validator.IsAllDataValid(data))
        {
            object b = null;
            foreach (var item in data.Items)
            {
                b = _businessLogic.DoSomeFancyCalculations(item);
            }

            if(_validator.IsBusinessDataValid(b))
            {
                return _navigation.ValidBusinessLogic();
            }
        }
        return _navigation.InvalidItems();
    }
}

Of course you could debate if all this logic should be placed in the GetDataAndNavigateSomewhereIfValid method. This is something you should decide for yourself. To me it looks like this method is doing way too much stuff.


问:
Which algorithms/data structures should I "recognize" and know by name?
I'd like to consider myself a fairly experienced programmer. I've been programming for over 5 years now. My weak point though is terminology. I'm self-taught, so while I know how to program, I don't know some of the more formal aspects of computer science. So, what are practical algorithms/data structures that I could recognize and know by name?

Note, I'm not asking for a book recommendation about implementing algorithms. I don't care about implementing them, I just want to be able to recognize when an algorithm/data structure would be a good solution to a problem. I'm asking more for a list of algorithms/data structures that I should "recognize". For instance, I know the solution to a problem like this:

You manage a set of lockers labeled 0-999. People come to you to rent
  the locker and then come back to return the locker key. How would you
  build a piece of software to manage knowing which lockers are free and
  which are in used?

The solution, would be a queue or stack.

What I'm looking for are things like "in what situation should a B-Tree be used -- What search algorithm should be used here" etc. And maybe a quick introduction of how the more complex(but commonly used) data structures/algorithms work.

I tried looking at Wikipedia's list of data structures and algorithms but I think that's a bit overkill. So I'm looking more for what are the essential things I should recognize?

答:
There is no "should". A. Get acquainted with the basic complexity classes (linear, logarithmic, etc.) B. Realize that you can do just about anything with a simple array as you can with a fancy data structure like a B-tree. The trick in choosing the appropriate structure/algorithm is lies in balancing performance, expected input size and implementation complexity.

Then there's abstract but immensely useful stuff (though usefulness is not immediately obvious): state machines, graph theory, convexity theory (linear programming, etc).

ContentLicense: CC BY-SA 3.0


答: The Algorithm Design Manual by Steven S. Skiena seems like the source you are searching. The second part is a classified list of problems with a review of the related algorithms. There is a web version.

Title: Which algorithms/data structures should I "recognize" and know by name?

Body:
I'd like to consider myself a fairly experienced programmer. I've been programming for over 5 years now. My weak point though is terminology. I'm self-taught, so while I know how to program, I don't know some of the more formal aspects of computer science. So, what are practical algorithms/data structures that I could recognize and know by name?

Note, I'm not asking for a book recommendation about implementing algorithms. I don't care about implementing them, I just want to be able to recognize when an algorithm/data structure would be a good solution to a problem. I'm asking more for a list of algorithms/data structures that I should "recognize". For instance, I know the solution to a problem like this:

You manage a set of lockers labeled 0-999. People come to you to rent
  the locker and then come back to return the locker key. How would you
  build a piece of software to manage knowing which lockers are free and
  which are in used?

The solution, would be a queue or stack.

What I'm looking for are things like "in what situation should a B-Tree be used -- What search algorithm should be used here" etc. And maybe a quick introduction of how the more complex(but commonly used) data structures/algorithms work.

I tried looking at Wikipedia's list of data structures and algorithms but I think that's a bit overkill. So I'm looking more for what are the essential things I should recognize?


问:
Better way to search for text in two columns
Here is the scenario. I am making a custom blogging software for my site. I am implementing a search feature. It's not very sophisticated - basically it just takes the search phrase entered and runs this query:

```<code>$query="SELECT * FROM `blog` WHERE `title` LIKE '%$q%' OR `post` LIKE '%$q%'";
</code>```

Which is meant to simply search the title and post body for the phrase entered. Is there a better way to do that, keeping in mind how long it would take to run the query on up to 100 rows, each with a post length of up to 1500 characters? I have considered using a LIMIT statement to (sometimes) restrict the number of rows that the query would examine. Good idea?

答: At the risk of sounding like Clippy, it looks like you're trying to enable full text search for your blog. (Or whatever else your example is serving as a proxy for.) I'd say, let the database do what it's optimized for and bring in a dedicated search engine like Lucene. </p>


答:
MIT publish free lecture notes, videos, assignments and exam material for Introduction to Algorithms. The lecture titles list the algorithms / data structures covered.

This is a peer-reviewed consensus on what you should know. It's probably a great learning resource, too.


答:
An objective response:

While my initial response to this question was based on my empirical experience as a soon-to-graduate CS student and my projected opinion of the type of people I wanted to work with in the CS field. There is actually an objective (with respect to the subjective opinions of the ACM SIGCSE and IEEE computing societies) answer. Every 10 years the ACM and the IEEE bodies cooperate on a joint publication that details suggestions for undergraduate computer science curriculum based on professional knowledge of the state of the computing industry. More information can be found at cs2013.org. The committee publishes a final report listing their curriculum recommendation.

That said, I still think my list is pretty good.

Original answer below.

What Should I Know?

Minimum

I think an adept programmer should have at least undergraduate level knowledge in Computer Science.  Sure, you can be effective at many jobs with only a small subset of Computer Science because of the rock solid community CS sits upon, and the narrowed focus of most professional positions.  Also, many people will further specialize after undergraduate study.  However, I do not think either are an excuse to not be privy of foundational CS knowledge.

To answer the title question, here is what an undergraduate CS student (the foundation for an adept programmer) should know upon graduation:

Data Structures

Machine Data Representation

Ones, Two's Complement, and Related Arithmetic

Words, Pointers, Floating Point

Bit Access, Shifting, and Manipulation

Linked Lists

Hash Tables (maps or dictionaries)

Arrays

Trees

Stacks

Queues

Graphs

Databases

Algorithms

Sorting:

Bubble Sort (to know why it's bad)

Insertion Sort

Merge Sort

Quick Sort

Radix style sorts, Counting Sort and Bucket Sort

Heap Sort

Bogo and Quantum Sort (=

Searching:

Linear Search

Binary Search

Depth First Search

Breadth First Search

String Manipulation

Iteration

Tree Traversal

List Traversal

Hashing Functions

Concrete implementation of a Hash Table, Tree, List, Stack, Queue, Array, and Set or Collection

Scheduling Algorithms

File System Traversal and Manipulation (on the inode or equivalent level).

Design Patterns

Modularization

Factory

Builder

Singleton

Adapter

Decorator

Flyweight

Observer

Iterator

State [Machine]

Model View Controller

Threading and Parallel Programming Patterns

Paradigms

Imperative

Object Oriented

Functional

Declarative

Static and Dynamic Programming

Data Markup

Complexity Theory

Complexity Spaces

Computability

Regular, Context Free, and Universal Turing Machine complete Languages

Regular Expressions

Counting and Basic Combinatorics

Beyond

To get into what you're asking about later in your question, if you are familiar with the above, you should be easily able to identify the appropriate pattern, algorithm, and data structure for a given scenario.  However, you should recognize that there is often no best solution.  Sometimes you may be required to pick the lesser of two evils or even simply choose between two equally viable solutions.  Because of this, you need the general knowledge to be able to defend your choice against your peers.

Here are some tips for algorithms and data structures:

Binary Search can only (and should) be used on sorted data.

Radix style sorts are awesome, but only when you have finite classes of things being sorted.

Trees are good for almost anything as are Hash Tables.  The functionality of a Hash Table can be extrapolated and used to solve many problems at the cost of efficiency.

Arrays can be used to back most higher level data structures.  Sometimes a "data structure" is no more than some clever math for accessing locations in an array.

The choice of language can be the difference between pulling your hair out over, or sailing through, a problem.

The ASCII table and a 128 element array form an implicit hash table (=

Regular expressions can solve a lot of problems, but they can't be used to parse HTML.

Sometimes the data structure is just as important as the algorithm.

Some of the above might seem like no brainers, and some may seem vague.  If you want me to go into more detail, I can.  But, my hope is when encountered with a more concrete question such as, "Design a function that counts the number of occurrences of every character in a String", you look to the tip about the ASCII table and 128 element arrays forming neat implicit hash tables for the answer.

Based off these ideas, I will propose an answer the locker problem outlined in your question.

Answer to the problem posed in your question.

This may not be the best answer to your question, but I think it's an interesting one that doesn't require anything too complex.  And it will certainly beat the time complexity of using a queue, or stack which require linear time to determine whether a locker is free or not.

You have 0-999 lockers.  Now, because you have a fixed number of lockers, you can easily conceive a hashing function with no collisions on the range 0-999.  This function is simply h(x) = x mod 1000.  Now, [conceptually] construct a hash table with integer keys and the contents of a 1000 element char array as your values.  If a customer wants to reserve locker 78 for use, simply put 78 into the hash function (returning 78), and then add that number to the base pointer of the array -- storing a true value at the location pointed to by the offset value.  Similarly, if you need to check whether 78 is in use, simply read the value stored at that location and check against true.

This solution operates in constant time for lookups and storage as opposed to a log(n) time storage and lookup in the case of a priority queue backed by a binary tree.  The description is intentionally verbose so you can see the higher concepts being boiled down into an efficient algorithm.

Now, you might ask, what if I need to know all of the available lockers, wouldn't a priority queue be better?  If there are k available lockers in the priority queue, iterating over all of them will take k steps.  Further, depending on your priority queue implementation, you might have to rebuild your priority queue as you look at it all.. which would take k*log(k) : (k < 1000) steps.  In the array solution, you only have to iterate of a 1000 element array and check which ones are open.  You can also add an available or used list to the implementation to check in k time only.


问:
I need an approach to the problem of preventing inserting duplicate records into the database
A webservice that I call returns a list of data. The data from the webservice is updated periodically, so a call to the webservice done in one hour could return the same data as a call done in an hour. Also, the data is returned based on a start and end date.

We have multiple users that can run the webservice search, and duplicate data is most likely to be returned (especially for historical data). However I don't want to insert this duplicate data in the database.

I've created a db table in which the data is stored (most important columns are)

Id int autoincrement PK
Date date not null        --The date to which the data set belongs.
LastUpdate date not null  --The date the data set was last updated.
UserName varchar(50)      --The name of the user doing the search.
```

I use sql server 2008 express with c# 4.0 and visual studio 2010. Entity Framework is used as the ORM. If stored procedures could be avoided in the proposed solution, then that will be a plus.

Another way of looking interpreting what I'm asking a solution for is as follows:
I have a million unique records in my table. A user does a new search. The search results from the user contains around 300k records of the data that is already in the db. An efficient solution to finding and inserting only the unique records is needed.

A combination of the Date, LastUpdate and UserName makes a record unique.

答:
Easy,

Create a unique name or number for every client that access the db ws.

Create a Table named "Downloaded" and insert a row every time a client access the ws and retrieve rows from the database. This row will contain the name of the client and the main table's row unique id.

The next time you access the ws for data, alter the select to include as o join, only the rows that were not "downloaded" by this user.

Got it?


答: Another approach:  Add a column to your database, "Hash".  It's a SHA-256 or the like--something big enough to be unique.  Require that the column be unique.</p>

Title: I need an approach to the problem of preventing inserting duplicate records into the database

Body:
A webservice that I call returns a list of data. The data from the webservice is updated periodically, so a call to the webservice done in one hour could return the same data as a call done in an hour. Also, the data is returned based on a start and end date.

We have multiple users that can run the webservice search, and duplicate data is most likely to be returned (especially for historical data). However I don't want to insert this duplicate data in the database.

I've created a db table in which the data is stored (most important columns are)

Id int autoincrement PK
Date date not null        --The date to which the data set belongs.
LastUpdate date not null  --The date the data set was last updated.
UserName varchar(50)      --The name of the user doing the search.
```

I use sql server 2008 express with c# 4.0 and visual studio 2010. Entity Framework is used as the ORM. If stored procedures could be avoided in the proposed solution, then that will be a plus.

Another way of looking interpreting what I'm asking a solution for is as follows:
I have a million unique records in my table. A user does a new search. The search results from the user contains around 300k records of the data that is already in the db. An efficient solution to finding and inserting only the unique records is needed.

A combination of the Date, LastUpdate and UserName makes a record unique.


问:
What are the typical applications of Lisp macros?
I am trying to learn some LISP and I have read a lot about the importance of LISP macros so I would like to get some working experience with them.

Can you suggest a practical application area that would allow me to use macros to solve a real-world problem, and to understand the usefulness of this programming construct?

NOTE

This is not a generic what project should I do next question. I am interested to understand which kinds of problems are typically solved by means of LISP macros. E.g., are they good for implementing abstract data types?
Why was this construct added to the language? What kinds of problems does it solve that cannot be solved by means of simple functions?

答:
The way I like to think about macros in common lisp is that they are functions that return code to be evaluated, but 'do not' evaluate their arguments before returning that code. Functions return something too, but they evaluate each argument before their body is evaluated. Macros do not.

Paul Graham in 'On Lisp' provides (IMHO) one of the best descriptions of the differences between macros and functions, and discusses their overlap and uniqueness. Many bits of code can be written as either a function or a macro, but there are cases where only a macro will work. Once you wrap your head around this, I think you've got the gist of macros in lisp.

As an example of a macro where a function will not work, check out 'aif' (anaphoric if). It's just a few lines of code, and my recommendation on where to start.

And do reference Common Lisp's version of anaphoric if, that takes advantage of intentional variable capture. Scheme's automatically-hygienic version is not IMO the 'real deal'. Variable capture is an important part of lisp macrology, and some of the more powerful and useful macros certainly take advantage of it.


问:
How do I architect 2 plugins that share a common component?
I have an object that takes in data and spits out a transformed output, called IBaseItem.

I also have two parsers, IParserA and IParserB. These parsers transform external data (in format dataA and dataB respectively) to a format usable by my IBaseItem (baseData).

I want to create 2 systems, one that works with dataA and one that works with dataB. They will allow the user to enter data and match it to the right plugins/implementations and transform the data to outData.

I want to write these traffic cops myself, but have other people provide the parsers and baseitem logic, and and as such am implementing these items as plugins (hence the use of interfaces). Other programmers can choose to implement 1 or both parsers.

Q: How should I structure the way base items and parsers are associated, stored, and loaded into each of my programs?

Class Relations:

What I've Tried:

Initially I though there should be a different dll for each of my 2 traffic cops, that each have a parser and baseitem in them. However, the duplication of baseitem logic doesn't seem right (especially if the base item logic changes).

I then thought the base items could all have their own dll, and then somehow associate parsers and baseitems (guids?), but I don't know if implementing the overhead id/association is adding too much complexion.

答:
I'd structure this solution like this:

You would have a single assembly which contains the IBaseItem contract (and any other contracts you expose to your consumers). Call this a contract assembly.

You may then need a second assembly which contains any shared code for your two parsers. Depending on the nature of your solution this shared code could go in the contract assembly, or may need to go into a base parser logic assembly. This base parser assembly would almost certainly need to reference the contract assembly to perform basic functions.

Finally, the two parsers can exist in their own projects and reference both of the other assemblies.

I don't follow with the mention of associating parsers with baseitems through guids. The question only mentions one baseitem, and each parser only knows one data type - it's a simple enough process to parse your one known input type into your one known output type.


问:
My boss decided to add a "person to blame" field to every bug report. How can I convince him that it's a bad idea?
In one of the latest "WTF" moves, my boss decided that adding a "Person To Blame" field to our bug tracking template will increase accountability (although we already have a way of tying bugs to features/stories). My arguments that this will decrease morale, increase finger-pointing and would not account for missing/misunderstood features reported as bug have gone unheard.

What are some other strong arguments against this practice that I can use? Is there any writing on this topic that I can share with the team and the boss?

答:
I believe the key aspect to watch in here is how open the communication is in the team towards the 'boss' and the other way around.
Finger-pointing is never good, however, from a management perspective, if one of your developers falls into the same issue several times, it might be time to step in and try to help him overcome this repetitive issue (e.g John is not testing properly the code: 3 production bugs in the last 3 months, let's give him a checklist so he remembers how his code is supposed to be and how he should test it).

From a development point of view, 'blaming' is already incorporated into a mainstream tool such as SVN, therefore I really don't see any harm in going "John, please fix that piece of crap you wrote" and putting a name next to it. JIRA also incorporates the name of a person when you file  a bug (however the field it's not really meant for the person who's responsible for it, it's pretty much so that someone fix it).

Here's the thing though, as many mentioned above by many, if a bug arises, it's a shared responsibility: from developer, to testers, to QA, to managers. If your boss at some point handles an angry client over the phone with things like "I'm so sorry, John never tested this properly", then I'd definitely be looking for another job. A good boss should go "we'll take care of this". No names, no finger-pointing, just solutions.

Again, I believe it's all about communication. Perhaps the only thing your boss wants to do is see who's having troubles in the dev team, or what kind of problems the team is having (perhaps for training sessions?), but I don't think you will find out exactly what's behind his decision (or better said, we posters/readers) unless you talk to your boss and your entire team.


问:
Java language book for an experienced programmer?

Possible Duplicate:

  Is there a canonical book for learning Java as an experienced developer?

I am looking for book to get up to speed with (start with) a Java language. I am experienced (more than 15 years) C# and C++ programmer with a bit of Python, so I don't need a book which starts with a programming concepts for a beginner. In fact I think I need a "Java language specification" sort of book.

I checked the answers to questions similar to mine and found that there two books  which is being recommended most: "Effective Java" and "Sun Certified Java Programmer".

After a quick look at the "Effective Java" I realised it should not be a book to start with, it is a good book (I read all books in Effective C++, STL series and liked them but they are more "good practices" books, rather than a book for a beginners)

"Sun Certified Java Programmer" looks closer to what I am after - but goes too slow for me.

So I did some more search and found these two books:

The Java(TM) Language Specification by Gosling himself

Java™ Programming Language, The (4th Edition) by Ken Arnold

I gather the first one a little bit dated and the second one is the best Java Language Reference books up to date, but I am not sure - as I am not a Java person to make such judgements.

After reading the language reference book I will start learning the basic libraries / packages / namespaces (collections, algorithms, IO, etc) and then something about UI architecture. But that will come later.

Question: - which Java Language reference book for an experienced programmer you can recomend ? and why?

Cheers.

答:
Six months ago I was also looking for books to get up to speed with Java. I was also coming from a background in C++ (as well as Perl, VBA, and JavaScript) and ended up purchasing the following:

Effective Java (2nd Edition) by Joshua Bloch

Java Concurrency in Practice by Brian Goetz

Java The Complete Reference by Herbert Schildt

Core Java, Volume I--Fundamentals by Cay Horstmann and Gary Cornell

I have since developed a Java application with more than 20,000 lines of code and found that the only books that I actually used were Effective Java and Java Concurrency in Practice. For basic language questions you can quickly get the answers from the Java Tutorials or by searching questions on stackoverflow.

In the case of Effective Java, it is the right place to start. The material is so fundamental to understanding Java idioms and avoiding common pitfalls that you cannot afford not to read it from the get go.


问:
IOS Variable vs Property
Just started diving into Objective-C and IOS development and was wondering when and the correct location I should be declaring variables/properties. The main piece of code i need explaining is below:

Why and when should i be declaring variables inside the interface statement and why do they have the same variable with _ and then the same one as a property. And then in the implementation they do @synthesize tableView = _tableView (I understand what synthesize does)

Thanks :-)

```<code>@interface ViewController : UIViewController <UITableViewDataSource, UITableViewDelegate>
{
    UITableView *_tableView;
    UIActivityIndicatorView *_activityIndicatorView;
    NSArray *_movies;
}

@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) UIActivityIndicatorView *activityIndicatorView;
@property (nonatomic, retain) NSArray *movies;
</code>```

答:
Why and when should i be declaring variables inside the interface
  statement

The instance variables are optionally defined inside the interface statement. You can alternatively define them in the implementation (or, for synthesised properties, not at all).

why do they have the same variable with _

Having an underscore is just a convention for "private" variables. The convention is followed in other languages as well. These are not mandatory.

and then the same one as a property. And then in the implementation
  they do @synthesize tableView = _tableView (I understand what
  synthesize does)

Properties are a means of providing external objects access to variables of this class. If you intend to use a variable inside the class and do not mean/need to expose it to outside classes, then you do not need to define a property for it.

If your variable name and property name were the same you only have to write @synthesize variableName. However, if they are different e.g., when _ is added to the name by convention, then the statement @synthesize variableName = _variableName is telling that the property variableName sets and get the variable _variableName.

Title: IOS Variable vs Property


问:
How to model the components of a non Information System?
I am working on a kernel-related project (specifically related to the TCP/IP stack of the kernel).

I need to build some models to describe the functionality and components of my system.
Initially I thought about using a Class Diagram, as it can describe the general architecture of my system. But it doesn't make sense since my code is VERY structured (written in standard C).

I also thought about DFDs: they'd describe the processes of my system, and how the data is flowing. But they contain something which doesn't really fit in: data-storages.
I have no databases here (at all).

For the functionality, other team members suggested using Activity and Sequence diagrams, which is kinda okay with me, but what about the system components?

So basically my question is: If I want to describe the components of my system, what do you suggest as a meaningful diagram ?

Again, the project is a research low-level systems-oriented project with almost no user-interface at all.

答:
I can only share my personal experience.

I have designed many systems in different environments (the most serious is the framework of some government agricultural data management systems), both backend and frontend things. I have tried to use UML many times (Rose, Enterprise Architect and ArgoUML), but failed with the same reason as yours. The UML notation is too limiting, and instead of allowing me to express and refine my ideas in an easy-to-share way, it tried to force my thinking into its terms, and I spent all my time in searching for the best diagram type. And anyway, not only I would have to spend a lot of time LEARNING that stuff, the results would be readable only for those who learned the same...

So, my result is: trash UML, and find a good charting software! My focus points in selection: first of all: draw smart, labeled lines that follow the shapes, and it should also allow easy reorganization, coloring, have a library of nice shapes. Your audience will love that too. Right now I have found gliffy.com, perhaps a bit too simple, but "good enough" tool for my current needs, and even my son can use it :-) But there are many others of this kind.

Spend your precious time on freely drawing your ideas, and create a simple, consistent notation (shape, color, line, text coding) that you can explain in just a minute - and express that this is NOT UML. For me, it works much better than the holy UML in reality, at least with my colleagues and audience.

And hey, I can write better code than what a UML tool generates, and would NEVER use the tool generated and updated code in a real system (only if I write that tool, which is in my long term scope :-) ).


答:
I were in your shoes ten years ago, tried "learning" Java after heavy C++ coding from books and examples - and failed.

Then I started working for a Java company, and they gave me the task to refactor an existing system, separate the reusable background framework from the custom business logic. At that time Java reference was unique: perfectly detailed explanations for ALL the language in a well-organized structure (now it's common). So I had the lang ref and the tutorial open in a browser, read and analyzed the code, and that's all. It was not easy, but I could manage it.

I think with your experience you don't need more. A good IDE (Eclipse is my choice), the Java tutorial for the first questions, the lang ref for the actual stuff - and tons of actual Java code with a real task to solve. And the holy Google with answers to the "beginner questions moving from C to Java" in the first months (yes, everyone has that period, bad, but it goes away). It will work.

Well, the bad side: today Java is not only the language, but the tons of tools (Spring, Maven, OSGI, Apache tools, not to mention the server side stuff), configs, magic, heavy googling. But I think anyone with a sane mind will let you familiarize yourself with the language itself before throwing you in the mud. ;-)

So: instead of any book, find a friend doing Java programming (or like me, a company that works in Java), explain the situation and start working.

My 2 cents.

Title: Java language book for an experienced programmer?

Body:
Possible Duplicate:

  Is there a canonical book for learning Java as an experienced developer?

I am looking for book to get up to speed with (start with) a Java language. I am experienced (more than 15 years) C# and C++ programmer with a bit of Python, so I don't need a book which starts with a programming concepts for a beginner. In fact I think I need a "Java language specification" sort of book.

I checked the answers to questions similar to mine and found that there two books  which is being recommended most: "Effective Java" and "Sun Certified Java Programmer".

After a quick look at the "Effective Java" I realised it should not be a book to start with, it is a good book (I read all books in Effective C++, STL series and liked them but they are more "good practices" books, rather than a book for a beginners)

"Sun Certified Java Programmer" looks closer to what I am after - but goes too slow for me.

So I did some more search and found these two books:

The Java(TM) Language Specification by Gosling himself

Java™ Programming Language, The (4th Edition) by Ken Arnold

I gather the first one a little bit dated and the second one is the best Java Language Reference books up to date, but I am not sure - as I am not a Java person to make such judgements.

After reading the language reference book I will start learning the basic libraries / packages / namespaces (collections, algorithms, IO, etc) and then something about UI architecture. But that will come later.

Question: - which Java Language reference book for an experienced programmer you can recomend ? and why?

Cheers.


问:
Programming knowledge vs. programming logic
Is there any difference between the two topics? I have seen companies asking for Good Programming knowledge some Good Programming logic.

I have seen this in Job profiles for a developer – for e.g. "good Programming logic", "strong Programming knowledge".

I believe that Programming knowledge is related to knowledge about the language in consideration and Programming logic is problem solving logic using programming (in general).

Please correct me if I am wrong. Also what is more important?

Edit: Do selection of components for application, designing interfaces validating user inputs fall under programming knowledge or Programming logic?

Does programming logic simply imply problem solving, or is there anything else which it should comprise of?

答:
Programming logic is defined as the application of mathematical/problem solving skills during a specfic progamming problem. Programming knowledge is the application of a specific programming language to enable the programmer to apply programming logic. Both are important in the process to solve a progamming problem.

The emphasis should be placed on problem solving skills though - the logic - getting good at solving complex problems. Once you have practiced this skill (it will take a while to start thinking out of the box) teach yourself a programming language to apply the logic.


答:
They sound very different to me, and I've had a hard time saying which one is more important.

You could be an amazing software maintainer, but a very bad programmer yourself. Some people are amazing at debugging code, finding their way through it, fixing it, and slightly improving it. They're often compared to janitors, but it's a disservice: they can have true knowledge and know-how to get things to a better state.

But they can still be awfully bad at writing new code and at designing and implementing algorithms. They can have an understanding of why things are generally better one way or another, and they can even understand after the fact the benefits of one design over another. But they have a hard time coming up with one themselves. They lack a deep understand of this logical and problem-solving mindset.

They're both important in my mind. You don't want only hackers who can come up with amazing solutions, but produce unmaintainable code for the next generations of eyeballs going to look at your codebase. It can be fine for prototyping and short-lived projects, but on a larger scale that can only fly for so long.

So the first group is also essential. But they wouldn't be able to design great software with the second group. It's quite symbiotic (and it's best when the qualities are indeed in the same developer). I'd guess if you see this as a chicken and egg problem, I'd have to admit that the logical kind matters a little bit more, for historical reasons, as they had to exist first to make head way. But does that mean they're more important in a software shop? I don't think so. You can produce great and successful software by plumbing things together and not inventing much.

Title: Programming knowledge vs. programming logic

Body:
Is there any difference between the two topics? I have seen companies asking for Good Programming knowledge some Good Programming logic.

I have seen this in Job profiles for a developer – for e.g. "good Programming logic", "strong Programming knowledge".

I believe that Programming knowledge is related to knowledge about the language in consideration and Programming logic is problem solving logic using programming (in general).

Please correct me if I am wrong. Also what is more important?

Edit: Do selection of components for application, designing interfaces validating user inputs fall under programming knowledge or Programming logic?

Does programming logic simply imply problem solving, or is there anything else which it should comprise of?


答:
There's a huge difference. Programming logic means one should be able to solve algorithmic problems, should be able to create generic, efficient code.They should be good at solving problems efficiently.
Programming knowledge is knowledge about general programming concepts, languages/language, and technologies</p>


问:
What are the key terms rvalue and lvalue?
Many of the times my compiler shows errors like Lvalue or Rvalue Required.

What are the Lvalues and Rvalues in C or any  programming languages?

Is a pointer constant a rvalue?

答:
The terms are somewhat language-specific; they were first introduced in CPL. Being an lvalue or an rvalue is a property of an expression; that is, every expression is either an lvalue or an rvalue.

You will often find explanations that deal with the left and right side of an assignment. That is the historical origin of the letters l and r in lvalue and rvalue, but it does not hold anymore. For example, there are lvalues that can not stand on the left side of an assignment (expressions denoting arrays and constant variables come to mind, but also class types where the assignment operator has been hidden or deleted), and at least in C++, there are rvalues that can stand on the left side of an assignment.

The best definition that I know of is: an lvalue is an expression to which the unary & operator can be applied, whereas an rvalue is an expression to which the unary & operator can not be applied. (This is not entirely true in C++ if you overload said operator, but that's probably very bad practice.)

Since C++11, the language also has the notions of xvalues, prvales und glvalues (see here and here).

Is pointer constant is a rvalue?

Expressions that denote pointer variables like p are lvalues. Expressions that denote pointer values like &i are rvalues. Both of them can be either const or non-const; that's completely orthogonal.

Java doesn't have the notion of lvalues, but in §15.1 the Language Specification states:

When an expression in a program is evaluated (executed), the result denotes one
  of three things:

A variable (§4.12) (in C, this [expression] would be called an lvalue)

A value (§4.2, §4.3)

Nothing (the expression is said to be void)


问:
It's ok to study the C++ from a book that only support the 1998 version of standard?
I have this big book that basically covers all the main aspects of the C++, the problem is that is pretty old according to the C++ standards of today, it's ok to use it?</p>

答:
The book itself isn't bad, but it is not a "language" book, but much more a "software engineering book".

It should not be used to learn a "language" but to learn "design techniques". The language is just a tool to implement the samples.

That said, we have to consider that in '98 C++ had a flawed template support and that many techniques where not been discovered/invented yet.

You must hence be conscious about some potential risks:

The author don't speach about a technique because not yet available. This is information incompleteness, you can fill-up with a further read. Not bad by itself... but why not start with a more recent reading?

The author is not (yet) aware of a potential problem a technique is teaching may have (because it has been discovered later). A bit more dangerous: if you don't fill this gap, you may be in troubles other are already away from.

The author is aware of certain problems and teach you techniques to avoid/solve them. May be now there are more effective/proper ways to avoid/solve those problems, making those techniques unnecessary overhead.

Moral: when talking about C++, books that predate 2003 should not be anymore considered.


问:
How to learn Cloud Computing and Big Data at home?
I want to learn Cloud Computing and Big Data at home.

Is it possible to learn these technologies on home PC?

Which technologies to learn in Cloud Computing?

Which technologies to learn Big Data (Hadoop)?

答:
Is it possible to learn these technologies on home PC?

Yes. For instance, you can work bith Google AppEngine's SDK entirely offline.

Google Code University also provides some starter courses and tutorials on Distributed and Cloud Computing.

Which technologies to learn in Cloud Computing?

Cloud Computing encompasses many things (ass buzzwords often do...).

You need to understand its core characteristics, its different service models and deployment models, and all the issues and troubles it comes bundled with and that need mitigation (the downside of buzzwords, is that it makes the greater public worry about stuff).

Once that's done, you can start experimenting with different software actors of the Cloud's landscape, and major providers like Google AppEngine (and Google's integrated services), Amazon AWS, Windows Azure, Heroku or CloundFoundry.

Which technologies to learn Big Data (Hadoop)?

The Wikipedia entry on Big Data's Technologies gives a (long-ish) list of pre-requisites, but if you wanted to be pointed at frameworks, then look at:

Apache Hadoop,

Apache Gora,

Apache Cassandra,

BigStreams,

...

View also:

Hadoop Fatigue: Alternatives to Hadoop

What are some open-source alternatives to Hadoop?

Alternatives to Hadoop for Big Data Management

Pictures courtesy of Wikipedia.


问:
Best practice for marking a bug as resolved in Bugzilla ?
I am wondering what is the best way to handle the situation of marking a bug as resolved and providing a version of component/product in which this fix can be found.

Context

For a project I am working on, we are using Bugzilla for issue tracking, and we have the following:

A product "A" with a version number like vA.B.C.D,

This product "A" have the following components:

Component "C1" with a version number like vA.B.C.D,

Component "C2" with a version number like vA.B.C.D,

Component "C3" with a version number like vA.B.C.D.

Internally we keep track of which component versions have been used to generate the product A version vA.B.C.D.

Example: Product "A" version v1.0.0.0 has been produced from component "C1" v1.0.0.3, component "C2" v1.3.0.0 and component "C3" v2.1.3.5.

And Product "A" version v1.0.1.0 has been produced from component "C1" v1.0.0.4, component "C2" v1.3.0.0 and component "C3" v2.1.3.5.

Each component is a SVN repository.

The person in charge of generating the product "A" have only access to the different components tags folder in SVN, and not the trunk of each component repository.

Problem

Now the problem is the following, when a bug is found in the product "A", and that the bug is related to Component "C1", the version of product "A" is chosen (e.g. v1.0.0.0), and this version allow the developer to know which version of component "C1" has the bug (here it will be v1.0.0.3). A bug report is created.

Now let's say that the developer responsible for component "C1" corrects the bug, then when the bug seems to be fixed and after some test and validation, the developer generates a new tag for component "C1", with the version v1.0.0.4.
At this time, the developer of component "C1" needs to update the bug report, but what is the best to do:

Mark the bug as resolved/fixed and add a comment saying "This bug has been fixed in the tags v1.0.0.4 of C1 component" ?

Keep the bug as assigned, add a comment saying "This bug has been fixed in the tags v1.0.0.4 of C1 component, update this bug status to resolved for the next version of the product that will be generated with the newest version (v1.0.0.4 of C1)" ?

Another possible way to deal with this problem.

Right now the problem is that when a product component CX is fixed, it is not sure in which future version of the product A it will be included, so it is for me not possible to say in which version of the product it will be solved, but it is possible to say in which version of the Component CX it has been solved. So when do we need to mark a bug as solved, when the product A version include the fixed version of CX, or only when CX component has been fixed ?

Thanks for your personal feedback and ideas about this !

答:
Fix in the component and integration of the fixed component into the product are two different activities.

There could be many ways to handle that, but no matter what you choose, you better take care that above difference is easy to understand by those using bug tracker.

Straightforward solution could be to simply use separate bugs for these separate activities.

Ticket 1234. Fix <particular issue> in component "C1".

Ticket 1235. Integrate fix of <ticket 1234> into product "A".

That way, you get clear description of what should be done, you can assign, prioritize and schedule the tickets independently, only taking into account that integration can start after component fix is completed.

Also, that way allows handling more "multi-level dependencies", like first one needs to fix a library component X, then integrate and adjust component C1 and only after that, integrate into product A.

That is a good idea indeed, however it means more process and overhead for "one" bug. Providing a specific format for the bug summary could make the management simpler ([INT. FIX] "summary of the bug previously reported")...

For the sake of completeness note that above approach ("one bug, two phases") may be viable, too - especially if vast majority of your bugs integrate that way (particular version of component -> particular version of product).

I've seen it done in at least two different projects and it worked OK. It typically took some time for team newcomers to get used to workflow and in cases of more complicated integration, we used separate bugs to track that, but that's minor.

Besides additional state (INT.FIX in above quote), points worth considering for "two-phase bug life cycle" are dedicated fields for component and product versions, as well as for responsible engineers. These are not a matter of life and death though - if there are no dedicated fields, relevant data can be extracted from bug changes history or put to comments.

And, since you mention overhead, my firm belief is that any substantial overhead that may be related to bug tracking means something is wrong either in bug tracker or in project management, or both.


问:
EJB Lifecycle and Relation to WARs
I've been reading up on EJBs (3.x) and believe I understand the basics. This question is a "call for confirmation" that I have interpreted the Java EE docs correctly and that I understand these fundamental concepts:

An EJB is to an App Container as a Web App (WAR) is to a Web Container

Just like you deploy a WAR to a Web Container, and that container manages your WAR's life cycle, you deploy an EJB to an App Container, and the container manages your EJB's life cycle

When the App Container fires up and deploys an EJB, it is given a unique "identifier" and URL that can be used by JNDI to look up the EJB from another tier (like the web tier)

So, when your web app wants to invoke one of your EJB's methods, it looks the EJB up using some kind of service locator (JNDI) and invoke the method that way

Am I on-track or way off-base here? Please correct me & clarify for me if any of these are incorrect. Thanks in advance!

答: You're essentially correct, note that with EJB 3.1, you can have light-weight EJBS that run in your web (servlet) container. Also the JNDI lookup can now be defined as a standard global lookup, so if you migrate to another app server your code doesn't have to change.</p>

Title: EJB Lifecycle and Relation to WARs


问:
svn usage advice
The probjem is that I have two sets of bugs top fix on the project. One to deploy in 5 days, and one to deploy in 10 days.

I am going to solve all the bugs before the fifth day but I do not want to deploy the last 5 before the release date (in 10 days).

How can I work on two separate codes and the merge all the modification?

Is it possible?

Do I have to create a branch?

答: Branching. Separate Branch for each bug (or batch of bug fixes), then you have complete control on when you merge back (ie release) the fixes. The book http://svnbook.red-bean.com/ is pretty good - work through that, or I'm sure there are lots of tutorials online.</p>

Title: svn usage advice


问:
Is there any logical relation between different types of UML diagrams?
I'm trying to find out ,that is there any relation between different types of UML diagrams, for example, once you developed a use case, should it be an event for each of them in a sequence diagram, or is there any exact relation between the use case and class diagrams.

By the way my main focus is on the below diagrams:

Use case

class diagram

activity

sequence

event

if you think I need any extra diagram to be included so it can be used to connecting the above diagrams to each other, please mention it too.

Thanks In Advance

答:
It is very common to have a sequence diagram for each a use case. In fact activity & sequence diagram can be both used to describe a process but in a different way (I prefer the sequence diagram).

I didn't use class diagram in UML much because I think this is something the developer must design himself. When we describe a system in UML, the difficulty is to be as much high level as possible but also as precise as possible. Class diagram is too precise.

I used Enterprise Architect extensively in the past (in fact I don't use it anymore because I stopped using UML completely) and it provides a very nice interface to link between different diagrams and components. I'm sure you'll find more information in its documentation.


问:
Architecture of a "website generator" web application
What is the most maintainable and efficient way to architect a web application who's purpose is to host and generate websites which can be customized to a certain degree?

There are a lot of these style of applications in the wild that generate all kinds of sites, from sites that host World of Warcraft guilds to other sites that do wedding site hosting. My question is, what is the basic architecture that these sites operate on?

I imagine there are two ways of thinking about this. A central set of code that all sites on the host run against, and it acts differently based on which site was visited. In this manner, when the base code is updated all sites are updated simultaneously.

Or, the code for an individual site exists in a silo, and is simply replicated to a new directory each time a site is created.  When an update needs to be applied, the code is pushed out to each site silo.

In my case, I am working in PHP with the CodeIgniter framework, however the answer need not be limited to this case. Which method (if any) creates a more maintainable and efficient architecture to manage this style of web application?

答:
In late 90s, I've worked on a couple of projects like this, and I used two different way to do it. Your defined them yourself pretty well.

First way is having everything dynamic and coming from the database. This is how most CMS are working right now, and I think it's the most effective way if you plan to host everything. I won't describe it here as it is pretty well defined everywhere.

The second way is having a real website generator. The components are the following:

Configuration: what features does the site owner needs? Does he needs a photo gallery or maybe a guestbook? (sorry I'm talking with the language of the late 90s here :)). What is defined here is used to assemble the available components of the generated website.

Individual data: it includes things like company description, logo, email or even domain names.

Based on that, the generator assemble the components (in my case it was source code such as ASP or PHP pages and a linked database) and the output would be a ready to be uploaded website.

The creation process could be 100% automated and the output downloaded at the end of the process. Update process would be no different that any downloadable application source code that is available, such as Wordpress. Finally, since the output is not compiled, the customer was able to customize everything.

In addition to this fairly simple way to generate websites, I recommend you to include a plugin system, just like Wordpress, that would allow your customer to create their own components.


答: Programming knowledge - is gained through reading and studying, while Programming logic is something that comes from experience to deal with different situations and finding solutions to them.


问:
Is the structure used for these web pages a design pattern?
I want to know if the structure for an ASP.NET website I'm working on uses a design pattern for it's web pages. If it is a design pattern, what is it called? The web pages have the following structure:

UserDetails page (UserDetails.aspx) - includes UserDetailsController.ascx user control. UserDetailsController.ascx includes sub user controls like UserAccountDetails.ascx and UserLoginDetails.ascx etc

Each sub user control contains a small amount of code/logic, the 'controller' user controls that host these sub user controls (i.e UserDetailsController.ascx) appear to call the business rules code and pass the data to the sub user controls.

Is this a design pattern? What is it called?

答:
Short answer: looks like a variation of a Master-child design.

Long answer: there are different standards how UI pattern is defined. To express them, i have combined listing that might be helpful to expand on this topic.

UI Patterns

UI Design patterns Introduction

40+ Helpful Resources On User Interface Design Patterns

MSDN - Design and Implementation Guidelines for Web Clients

ASP.NET Design Patterns


答:
Programming Knowledge is the understanding of how to use a programming language, what it's syntax is, keywords, code usage (and understanding OOP if it is an object orientated language). This knowledge can be gained through reading textbooks and studying the language and concepts.

Programming Logic is the ability to solve problems and to think in an abstract way when using the programming language. This is different to programming knowledge because programming logic is gained with experience and practice.

Some programmers may have a good knowledge of a programming language but not had a lot of experience in solving problems using it. And equally, some programmers may have good logical reasoning skills but have limited knowledge of the programming language. Skill in both programming knowledge and programming logic can be gained, but the latter comes with experience.


问:
Open .doc file from my website in browser
What's the best way to give the end-user of my web application the ability to open, edit and save (via browser) word documents that are stored in my database?

I have this working by doing an html conversion of the file (via Aspose Words) but this method seems not even close to flawless and i'm trying to improve this. Is integrating with google docs possible/good? Their edition seems awesome and very powerful.

I can't use any Microsoft Word objects (and this is even discouraged by MS).

EDIT: The application is developed in .NET and currently uses the .NET framework 2.0. However, as this is fairly obsolete the idea is to restart from scratch and therefore use the 4.0 framework and C# or VB.

答:
You could look into using WebDAV.  This is what Sharepoint uses, for example, to achieve this functionality.  It basically allows for a URL to act as a hard drive for the purpose of reading/writing files.  Alternatively, you could just use Sharepoint for this functionality, but that would require a large amount of customization which isn't the easiest thing to do.

You could use a browser plug-in such as Silverlight or Flash.  I have done this via Silverlight using COM interop with Word (as of SL5 this can be done in browser).  I'm not sure if Flash has the same capabilities as I'm less familiar with it, but plug-ins have elevated privileges on the user's machine so it should be a lot easier to achieve this functionality.

You could create a client-side WPF application and have it installed on the user's machine via ClickOnce so that it is a fairly seamless experience.  We have done this with one of our internal systems and it worked fine.  Not sure how well it would work in a public-facing scenario, though.

Most of those options won't work in every browser on every platform.  However, since you are targeting MS Word, I'm making an assumption that your goal is not to be 100% standards-compliant to get maximum reach.  Most of these solutions will work for a majority of users on the major platforms.

Those options make the most sense if you are on top of a .NET stack already.  There are many other potential options.  If you give a better idea of what your current technology stack looks like you might get some more specific recommendations.


问:
Efficient Trie implementation for unicode strings
I have been looking for an efficient String trie implementation. Mostly I have found code like this:

Referential implementation in Java (per wikipedia)

I dislike these implementations for mostly two reasons:

They support only 256 ASCII characters. I need to cover things like cyrillic.

They are extremely memory inefficient.

Each node contains an array of 256 references, which is 4096 bytes on a
    64 bit machine in Java. Each of these nodes can have up to 256
    subnodes with 4096 bytes of references each. So a full Trie for
    every ASCII 2 character string would require a bit over 1MB. Three character strings? 256MB just for arrays in nodes. And so on.

Of course I don't intend to have all of 16 million three character strings in my Trie, so a lot of space is just wasted. Most of these arrays are just null references as their capacity far exceeds the actual number of inserted keys. And if I add unicode, the arrays get even larger (char has 64k values instead of 256 in Java).

Is there any hope of making an efficient trie for strings?
I have considered a couple of improvements over these types of implementations:

Instead of using array of references, I could use an array of primitive integer type, which indexes into an array of references to nodes whose size is close to the number of actual nodes.

I could break strings into 4 bit parts which would allow for node arrays of size 16 at the cost of a deeper tree.

答:
if you encode up the strings into UTF8 you can use the standard 256 branching trie and still be unicode compatible

also you should note that only 70 or so characters out of the possible 128 ascii characters (which all encode to 1 byte in UTF8) will be found most heavily you can optimize for that (like include the common digraphs in place of the unused control characters)


问:
Strategy vs Delegates
Can the Strategy design pattern entirely replace delegates?

In Java, for example, there are no delegates. Is it possible to gain all the features of delegates by using Strategy design pattern?

Edit: I see there is some ambiguity in my question. By delegates I mean the feature of the language, C# for instance.

答:
Is it possible to gain all the features of delegates by using Strategy design pattern?

Not exactly.

In C#, delegates are used to implement the strategy pattern nicely and easily. Sometimes, virtual dispatch via inheritance is used to implement the strategy pattern because it fits better for the problem. Rarely, overloaded dynamic methods are used.

Java really only has the second as an option at the moment.

It's not really correct to say that the strategy pattern can provide delegate behavior because one is a design pattern and the other is a construct. The whole Turing completeness thing says that Java can emulate delegate behavior, but a number of the delegate's features (capturing local variables, multi-casting) will fall outside of what a Strategy pattern solves.

Title: Strategy vs Delegates


问:
Company PC refresh, laptop or desktop?
My company is getting PC refreshes with a choice of to have a desktop or laptop.  Each one seems to have its pros and cons. Would you want the flexibility and freedom of the laptop but take the risk of working extra hours at home? Or a desktop limited to one place, but not having to worry about taking work home and disrupting home time?

I'm not asking what would be better for coding, but more for convenience and productivity.  I currently have a desktop and work about 8 to 9 hours a day, with only coming in on the weekends for when we get behind on major deadlines. I love developing but I also have quite a busy life after work. I feel that having a work laptop will only haze the line of work and home.

答:
Definitely a desktop PC, with (and this is very important) a very large monitor.

If you want productivity, large screen is your best option. I don't think that's something a laptop can match..

ContentLicense: CC BY-SA 2.5

Title: Company PC refresh, laptop or desktop?


答:
Programming knowledge
means knowing about the concepts of the particular programming language that offers the features that can commonly solve the problem.

Programming logic
means applying the programming knowledge to frame a programming logic that would work to solve the problem.

So one is concerned with the concepts and another is concerned with the logic.


问:
ORM and component-based architecture
I have joined an ongoing project, where the team calls their architecture "component-based". The lowest level is one big database. The data access (via ORM) and business layers are combined in various components. E.g., there's a component for handling bank accounts, one for generating invoices, etc. So every component contains the data access to only a part of the schema. My issue is the coupling of data access and business logic in such a structure, because while such a partition makes sense for business logic, it complicates data access.

From my point of view the separation of the data access layer into various components seems counterproductive, because it denies us the relational mapping capabilities of the ORM. E.g., when I want to query all invoices for one customer I have to identify the customer with the "customers" component and then make another call to the "invoices" component to get the invoices for this customer. The entity Customer can't have an Orders property, because Orders are mapped in a different component.

Does anybody have some advice? Have I overlooked something?

答:
Sounds like a relatively clean and encapsulated layout of the underlying data structures.

While there are arguments to be made against encapsulation, I'm not certain any of them are valid in this case.  (Nor are they valid in any case, but I'm trying to be generous here and not show my bias.)

Here's some of the benefits I see you getting:

Easy ability to identify which structures are needed to assemble information.  So that translates into a shorter learning curve in understanding the application.

Clearly defined scope for what needs to be tested when changes are incurred.

Flexibility to adapt the business logic as the business changes to the underlying data structures.

Understandably, you can't provide all the details of the application stack.  So presumably, you're running into problems and / or it feels cumbersome to make changes at the business logic layer.   Have you considered adding an intermediate layer that provides the compound objects you're looking for?

In other words, have an object that combines invoices + customer info so your view or view-model can manipulate that object instead of having two different objects to work with.

The downside of this approach is that it's more code to write and maintain.  It may or may not be worth the additional effort.

Title: ORM and component-based architecture


答:
What are you using this trie for? What is the total number of words that you plan to hold, and what is the sparseness of their constituent characters? And most important, is a trie even appropriate (versus a simple map of prefix to list of words)?

Your idea of an intermediate table and replacing pointers with indexes will work, provided that you have a relatively small set of short words and a sparse character set. Otherwise you risk running out of space in your intermediate table. And unless you're looking at an extremely small set of words, you won't really save that much space: 2 bytes for a short versus 4 bytes for a reference on a 32-bit machine. If you're running on a 64-bit JVM, the savings will be more.

Your idea about breaking the characters into 4-bit chunks probably won't save you much, unless all of your expected characters are in an extremely limited range (maybe OK for words limited to uppercase US-ASCII, not likely with a general Unicode corpus).

If you have a sparse character set, then a HashMap<Character,Map<...>> might be your best implementation. Yes, each entry will be much larger, but if you don't have many entries you'll get an overall win. (as a side note: I always thought it was funny that the Wikipedia article on Tries showed -- maybe still does -- an example based on a hashed data structure, completely ignoring the space/time tradeoffs of that choice)

Finally, you might want to avoid a trie altogether. If you're looking at a corpus of normal words in a human language (10,000 words in active use, with words 4-8 characters long), you'll probably be MUCH better off with a HashMap<String,List<String>, where the key is the entire prefix.

Title: Efficient Trie implementation for unicode strings

Body:
I have been looking for an efficient String trie implementation. Mostly I have found code like this:

Referential implementation in Java (per wikipedia)

I dislike these implementations for mostly two reasons:

They support only 256 ASCII characters. I need to cover things like cyrillic.

They are extremely memory inefficient.

Each node contains an array of 256 references, which is 4096 bytes on a
    64 bit machine in Java. Each of these nodes can have up to 256
    subnodes with 4096 bytes of references each. So a full Trie for
    every ASCII 2 character string would require a bit over 1MB. Three character strings? 256MB just for arrays in nodes. And so on.

Of course I don't intend to have all of 16 million three character strings in my Trie, so a lot of space is just wasted. Most of these arrays are just null references as their capacity far exceeds the actual number of inserted keys. And if I add unicode, the arrays get even larger (char has 64k values instead of 256 in Java).

Is there any hope of making an efficient trie for strings?
I have considered a couple of improvements over these types of implementations:

Instead of using array of references, I could use an array of primitive integer type, which indexes into an array of references to nodes whose size is close to the number of actual nodes.

I could break strings into 4 bit parts which would allow for node arrays of size 16 at the cost of a deeper tree.


答:
A delegate is a just a class with no data and one method.  This is easy to implement in almost any OO language, including even C#, and certainly Java.

C# (using a delegate):

```<code>public delegate bool Test( int, int );
// And in some other class/method:
    SortEm.sort( ilist, (a, b) => a < b );
// And in static class SortEm:
public static void sort( int[] list, Test test )  {
    ...
    if (test( x, y ))  {
    ...
}
</code>```

Java:

```<code>public interface JDelegate  {
    public boolean test( int a, int b );
}
// And in some other class/method:
    SortEm.sort( ilist,
        // Anonymous Class
        new JDelegate()  {
            @Override public boolean test( int a, int b )  { return a < b; }
        }
    );
// And in class SortEm:
public static void sort( int[] list, JDelegate sorter )  {
    ...
    if (sorter.test( x, y ))  {
    ...
}
</code>```

The Java needs a bit more typing.  It does use existing concepts rather than creating new ones (delegate, for instance), which makes it easier if you're coming back to Java after spending a year on C.  Also, the "JDelegate" interface can become a lot more elaborate if needed, as can the class actually passed, which could be a named (rather than anonymous) class implementing JDelegate.

The big C# edge in this is that the most commonly used section in this code is the call to sort--one line versus four, in this case.  But the functionality is there in Java and probably any OO language.

Doing this in C# without delegates is left as an exercise for the reader.

Title: Strategy vs Delegates

Body:
Can the Strategy design pattern entirely replace delegates?

In Java, for example, there are no delegates. Is it possible to gain all the features of delegates by using Strategy design pattern?

Edit: I see there is some ambiguity in my question. By delegates I mean the feature of the language, C# for instance.

Body:
A delegate is a just a class with no data and one method.  This is easy to implement in almost any OO language, including even C#, and certainly Java.

C# (using a delegate):

public delegate bool Test( int, int );
// And in some other class/method:
    SortEm.sort( ilist, (a, b) => a < b );
// And in static class SortEm:
public static void sort( int[] list, Test test )  {
    ...
    if (test( x, y ))  {
    ...
}

Java:

public interface JDelegate  {
    public boolean test( int a, int b );
}
// And in some other class/method:
    SortEm.sort( ilist,
        // Anonymous Class
        new JDelegate()  {
            @Override public boolean test( int a, int b )  { return a < b; }
        }
    );
// And in class SortEm:
public static void sort( int[] list, JDelegate sorter )  {
    ...
    if (sorter.test( x, y ))  {
    ...
}

The Java needs a bit more typing.  It does use existing concepts rather than creating new ones (delegate, for instance), which makes it easier if you're coming back to Java after spending a year on C.  Also, the "JDelegate" interface can become a lot more elaborate if needed, as can the class actually passed, which could be a named (rather than anonymous) class implementing JDelegate.

The big C# edge in this is that the most commonly used section in this code is the call to sort--one line versus four, in this case.  But the functionality is there in Java and probably any OO language.

Doing this in C# without delegates is left as an exercise for the reader.


答:
I have always preferred a desktop, but not for any of the reasons you mention.  I preferred a desktop because it used to be nearly impossible (or very cost-prohibitive) to match the performance of a desktop with a laptop.  However, with solid state drives and the ability to get RAM amounts up to 8GB+ in laptops the lines have blurred.

At each place I have worked in the last few years, I have had the ability to remote in to my desktop.  This negates what you describe as being "more tied to work" simply because of having a laptop.

However, another positive of a laptop would be having the option to easily code elsewhere without the need to remote into the desktop - like from a conference room, the couch, etc.

Title: Company PC refresh, laptop or desktop?

Body:
My company is getting PC refreshes with a choice of to have a desktop or laptop.  Each one seems to have its pros and cons. Would you want the flexibility and freedom of the laptop but take the risk of working extra hours at home? Or a desktop limited to one place, but not having to worry about taking work home and disrupting home time?

I'm not asking what would be better for coding, but more for convenience and productivity.  I currently have a desktop and work about 8 to 9 hours a day, with only coming in on the weekends for when we get behind on major deadlines. I love developing but I also have quite a busy life after work. I feel that having a work laptop will only haze the line of work and home.


答: My general rule when it comes to ORMs is to keep one component per database schema, if you have separate components to deal with the same database I would agree that you are missing on ORM benefits.</p>

Title: ORM and component-based architecture

Body:
I have joined an ongoing project, where the team calls their architecture "component-based". The lowest level is one big database. The data access (via ORM) and business layers are combined in various components. E.g., there's a component for handling bank accounts, one for generating invoices, etc. So every component contains the data access to only a part of the schema. My issue is the coupling of data access and business logic in such a structure, because while such a partition makes sense for business logic, it complicates data access.

From my point of view the separation of the data access layer into various components seems counterproductive, because it denies us the relational mapping capabilities of the ORM. E.g., when I want to query all invoices for one customer I have to identify the customer with the "customers" component and then make another call to the "invoices" component to get the invoices for this customer. The entity Customer can't have an Orders property, because Orders are mapped in a different component.

Does anybody have some advice? Have I overlooked something?


问:
Is HTML5 more secure to develop for than Silverlight?
I'm learning Silverlight, and I know that if I master it, I can apply the same concepts to WPF, which means I can do either web or desktop development pretty easily. But I've read articles and followed the discussion online, and I understand HTML5 is gaining traction for being cross-platform, and a lot of people seem to be moving to HTML5.

From my understanding, any HTML5 application would be built with HTML and JavaScript (or Flash). But is it secure? It seems like anyone can easily use their browser's "view source" option and grab your code. Is this something I should be worried about, or is there a way to protect against it?

答:
From my understanding, any HTML5 application would be built with HTML and JavaScript (or Flash). But is it secure? It seems like anyone can easily use their browser's "view source" option and grab your code. Is this something I should be worried about, or is there a way to protect against it?

If you are learning SL, then go ahead. But remember, even Silverlight and Flash code can be decoded and the cracker can read your code.


问:
using static methods and classes
I know that static methods/variables are associated with the class and not the objects of the class and are useful in situations when we need to keep count of, say the number of objects of the class that were created. Non-static members on the other hand may need to work on the specific object (i.e. to use the variables initialized by the constructor)

My question what should we do when we need neither of the functionalities?

Say I just need a utility function that accepts value(s) and returns a value based solely on the values passed. I want to know whether such methods should be static or not. How is programming efficiency affected and which is a better coding practice/convention and why.

PS: I don't want to spark off a debate, I just want a subjective answer and/or references.

答:
It's pretty standard in Java to make such methods static and put them in "classes" with other static methods.  You certainly wouldn't want to make the methods non-static--you'd confuse everybody, including the optimizers.  I suppose the designers could have thought of a name besides "class" ("namespace"?) to hold these methods/functions, but most of us have enough to remember as is.  I'll admit, having to add a private constructor to a "static" class seems a bit silly, but it gets the job done without adding new rules.

C# is a bit more explicit, with a static class (no double quotes around static), no need for a private constructor, and enforcing of the static-methods-only rule.

(Java has a "static class", but it's something completely different, primarily intended, no doubt, to confuse discussions like this one.)

Title: using static methods and classes


答:
Continuing with the example of System.Math in C#, some languages such as Nemerle allow you to add a using statement which effectively lets you use a classes behaviour as free functions, as well as direct access to its constants & other static members.

```<code>using System.Math // using statement at class level

public class Example
{
    public TestMethod() : void
    {
        def radians = Pi; // direct access to Math.Pi

        def x = Sin(radians); // direct access to Math.Sin & Math.Cos
        def y = Cos(radians);
    }
}
</code>```

In essence this allows you to treat a class as a namespace, which as DeadMG pointed out is basically what System.Math is...

Title: using static methods and classes

Body:
I know that static methods/variables are associated with the class and not the objects of the class and are useful in situations when we need to keep count of, say the number of objects of the class that were created. Non-static members on the other hand may need to work on the specific object (i.e. to use the variables initialized by the constructor)

My question what should we do when we need neither of the functionalities?

Say I just need a utility function that accepts value(s) and returns a value based solely on the values passed. I want to know whether such methods should be static or not. How is programming efficiency affected and which is a better coding practice/convention and why.

PS: I don't want to spark off a debate, I just want a subjective answer and/or references.

Body:
Continuing with the example of System.Math in C#, some languages such as Nemerle allow you to add a using statement which effectively lets you use a classes behaviour as free functions, as well as direct access to its constants & other static members.

using System.Math // using statement at class level

public class Example
{
    public TestMethod() : void
    {
        def radians = Pi; // direct access to Math.Pi

        def x = Sin(radians); // direct access to Math.Sin & Math.Cos
        def y = Cos(radians);
    }
}

In essence this allows you to treat a class as a namespace, which as DeadMG pointed out is basically what System.Math is...


问:
Designing an email system to guarantee delivery

Summary:

We are looking to expand our use of email for notification purposes.  We understand it will generate more inbox volume, but we are being selective about which events we fire notification on in order to keep the signal-to-noise ratio high.

The big question we are struggling with is designing a system that guarantees that the email was delivered.  If an email isn't delivered, we will consider that an exception event that needs to be investigated.   In reality, I say almost guarantees because there aren't any true guarantees with email.  We're just looking for a practical solution to making sure the email got there and experiences others have had with the various approaches to guaranteeing delivery.

TL;DR - How do we go about designing a system to guarantee delivery of emails?  What techniques should we consider so we know the emails were delivered?

Additional concerns:

Our biggest area of concern is what techniques to use so that we know when a message is sent out that it either lands in an inbox or it failed and we need to do something else.

Additional requirements:

We're not at the stage of including an escalation response, but we'll want that in the
future or so we think.

Most notifications will be internal to our enterprise, but we will have some notifications being sent to external clients.

Some of our application is in a hosted environment.  We haven't determined if those servers can access our corporate email servers for relaying or if they'll be acting as their own mail servers.

Base design / modules (at the moment):

A module to assign tracking identification

A module to send out emails

A module to receive delivery notification (perhaps this is the same as the email module)

A module that checks sent messages against delivery notification and alerts on undelivered email.

Some references:

Atwood: Send some email

Email Tracking

Approaches we've considered:

Request a response (aka read-receipt or Message Disposition Notification).

Seems prone to failure since we have cross-compatibility issues due to differing mail servers and software.

Return receipt (aka Delivery Status Notification).

Not sure if all mail servers honor this request or not

Require an action and therefore prove reply.

Seems burdensome to force the recipients to perform an additional task not related to resolving the issue.  And no, we haven't come up with a way of linking getting the issue fixed to whether or not the email was received.

Force a click-through / Other site sign-in.

Similar to requiring some sort of action, this seems like an additional burden and will annoy the users.  On the other hand, it seems the most likely to guarantee someone received the notification.

Hidden image tracking.

Not all email providers automatically load the image, and how would we associate the image(s) with the email tracking ID?

Outsource delivery.

This gets us out of the email business, but goes back to how to guarantee the out-sourcer's receipt and subsequent delivery to the end recipient.

As a related concern, there will be an n:n relationship between issue notification and recipients.

The 1 issue : n recipients subset isn't as much of a concern although if we had a delivery failure we would want to investigate and fix the core issue.

Of bigger concern is n issues : 1 recipient, and we're specifically concerned in making sure that all n issues were received by the recipient.  How does forum software or issue tracking software handle this requirement?  If a tracking identifier is used, Where is it placed in the email?  In the Subject, or the Body?

答:
Technically, you can't, since SMTP is designed in a way that you can't know for sure if the email was delivered.

If you're sending legitimate emails and their potential readers are willing to help you (for example some critical notifications sent to the employees of your company), then "Request a delivery receipt" option comes to mind.

Of course, if one of the employees don't want to send the receipts back, you'll never know if the emails were delivered or not. The same comes for people who explicitly set their email client to discard any delivery receipt requests.

If you want to be sure the messages are "technically delivered" to the users, then consider another way, like showing those messages on your corporate website and log the access of the users.

Last but not least, even if a message is displayed to a user, it doesn't mean the user read it.


答: The only reliable way to guarantee an email was received/at least skimmed is including a verification link the receiver must click. If this is too inconvenient, which is likely, then you need to rethink your reliance on email for message delivery. Email was never intended to be used in this manner so it was never designed to make it easy to implement this behavior. Your workflow process needs to be revisited if dependency on email notifications is critical to system success.</p>

Title: Designing an email system to guarantee delivery

Body:
Summary:

We are looking to expand our use of email for notification purposes.  We understand it will generate more inbox volume, but we are being selective about which events we fire notification on in order to keep the signal-to-noise ratio high.

The big question we are struggling with is designing a system that guarantees that the email was delivered.  If an email isn't delivered, we will consider that an exception event that needs to be investigated.   In reality, I say almost guarantees because there aren't any true guarantees with email.  We're just looking for a practical solution to making sure the email got there and experiences others have had with the various approaches to guaranteeing delivery.

TL;DR - How do we go about designing a system to guarantee delivery of emails?  What techniques should we consider so we know the emails were delivered?

Additional concerns:

Our biggest area of concern is what techniques to use so that we know when a message is sent out that it either lands in an inbox or it failed and we need to do something else.

Additional requirements:

We're not at the stage of including an escalation response, but we'll want that in the
future or so we think.

Most notifications will be internal to our enterprise, but we will have some notifications being sent to external clients.

Some of our application is in a hosted environment.  We haven't determined if those servers can access our corporate email servers for relaying or if they'll be acting as their own mail servers.

Base design / modules (at the moment):

A module to assign tracking identification

A module to send out emails

A module to receive delivery notification (perhaps this is the same as the email module)

A module that checks sent messages against delivery notification and alerts on undelivered email.

Some references:

Atwood: Send some email

Email Tracking

Approaches we've considered:

Request a response (aka read-receipt or Message Disposition Notification).

Seems prone to failure since we have cross-compatibility issues due to differing mail servers and software.

Return receipt (aka Delivery Status Notification).

Not sure if all mail servers honor this request or not

Require an action and therefore prove reply.

Seems burdensome to force the recipients to perform an additional task not related to resolving the issue.  And no, we haven't come up with a way of linking getting the issue fixed to whether or not the email was received.

Force a click-through / Other site sign-in.

Similar to requiring some sort of action, this seems like an additional burden and will annoy the users.  On the other hand, it seems the most likely to guarantee someone received the notification.

Hidden image tracking.

Not all email providers automatically load the image, and how would we associate the image(s) with the email tracking ID?

Outsource delivery.

This gets us out of the email business, but goes back to how to guarantee the out-sourcer's receipt and subsequent delivery to the end recipient.

As a related concern, there will be an n:n relationship between issue notification and recipients.

The 1 issue : n recipients subset isn't as much of a concern although if we had a delivery failure we would want to investigate and fix the core issue.

Of bigger concern is n issues : 1 recipient, and we're specifically concerned in making sure that all n issues were received by the recipient.  How does forum software or issue tracking software handle this requirement?  If a tracking identifier is used, Where is it placed in the email?  In the Subject, or the Body?


问:
Release roadmap with scrum
I need to prepare an internal product release road-map for product being built via scrum methodology, and have some difficulty correlating sprints to the road-map.

The main problem is that as I don't have effort estimations for every story, because these prepared immediately before each sprint, so I don't know what will make into which sprint.

I'm fine with changing the road-map as the development goes on, but need it to give at least some indication when things planned to be released.

So what would be the best way to do this, other then guestimating the whole backlog?

Thanks for any idea.

答:
Last time I did something like this we got the whole team together and estimated the entire backlog. It's darned annoying, but I couldn't see any way around it.

It's all guesswork at that point, of course, because you don't even really know what you'll be doing by the end because you can guarantee that something is going to change. But it's the only way I know how to take a defensible guess at the end date.

If you can, implement the roadmap in your tracking system rather than as a list of dates on paper. That way you are emphasizing the ephemeral nature of the dates, to hopefully give your audience a better feel that these aren't 'written in stone' in any way.

Title: Release roadmap with scrum


问:
Small assembly language project for practice
I am learning assembly language for x86 architecture. But, i am unable to find any practice problems so that i can test my skills. Can you suggest me some practice problems or some small assembly language project to improve my skills.??

thanks in advance

答:
When I was studying assembly at university we were doing small applications all the time. We had tasks like input, output, different sums and sorts (for using loops), 'drawing' some images, like circles, with points, etc.

There also were large projects. The most interesting one is writing a driver. You could take a small device, like mouse, and try to implement a driver for it. If you also add some tests along to find out, for example, where is the problem in case smth is wrong, that would be great experience. Writing a driver properly requires good knowledge of the language, some research on the device and ports, and also pieces of code for testing.

This is project you wouldn't call small, but if you can implement this all than be sure you do know the assembly language!


答:
Despite my habit of using my desktop as a leg rest, both at home and at work, I'd have to go with laptop.

Get one that comes with a base station you can plug it into to connect 1+ monitors to it, and you've got a lot of screen space, possibly more than you could get with a desktop, since it has a monitor built-in already. You can also connect a keyboard & mouse to it, so it's indistinguishable from a desktop when being used.

Even if you're not planning to take it home, just having the portability in case you need to bring it to a meeting, go on site and have it with you, or anything else, can be a blessing.

Title: Company PC refresh, laptop or desktop?


答:
You may concentrate on optimization of existing sample codes. There are some good resources to look for:

Assembly-language-programing

Lab 2: Assembly Language Programming

Link 3

Good Webster resources - /216.92.238.133/Webster/

PC-231 Assembly Language Exercises

Ideas 4 a small assembly project, any 1?

Small assembly code sequence optimization (intel x86)

another collection

Pdf file of interesting problems

The most interesting and a little complex tasks might be writing a compatible driver to devices that are handy to your needs.

Title: Small assembly language project for practice

Body:
I am learning assembly language for x86 architecture. But, i am unable to find any practice problems so that i can test my skills. Can you suggest me some practice problems or some small assembly language project to improve my skills.??

thanks in advance