Jack @ ASP.NET

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Entries Tagged ‘time’

Random in Java

Random in Java:

public Random()

It will create a new random number generator. Its seed is initialized to a value based on the current time:

public Random() { this(System.currentTimeMillis()); }

Based on this, two Random objects created within the same millisecond will have the same sequence of random numbers.

Duration and method of victory in football games

A standard adult football match is divided into two periods of 45 minutes each half, said. Each semi-continuous operation, which means that the clock did not stop when the ball is impossible to play. Usually have 15 minutes rest between half-time intermission. The end game is known as full-time. The official referee of the game timer, and can replace the lost time, note, or other injured players suspended allowance. This increases the time often referred to as stoppage time or injury time in the referee’s discretion. Only when the referee sounded the game ended. Where the appointment of the fourth official in the game, towards the end of the half, the referee signals how the injury time, he intends to increase the number of minutes. Then the fourth official notice, held a board, showing the number of players and spectators. Hint of injury time may be further extended by the referee. Added time because the events in 1891, took place in Stoke and Aston Villa in a game introduction. Trailing 1-0 only two minutes, Stoke were awarded a penalty. Villa’s goalkeeper kicked the ball out of the ground, the ball has been restored by the then 90 minutes later, the game is over. See mini-helmets.aspx. The same law also means that either half of the time, until the penalty kick to extend or regain complete, so there is no game shall end with a penalty to be taken.

In the league match, the game may end in a draw, but in some knockout competitions if the game time in the regular season into extra time may be, of which there are two parallel 15 minutes form the end. If the score is still tied after extra time, some competitions allow the use of the penalty shootout (officially known as the laws of the game “from the penalty kick”), to determine which team will enter the next phase of the competition. Goal in overtime during the final score of the game number, and the penalty kick is used to determine the team, the development of the next part of the game (most goals in a penalty shoot part, not in the final score .)

Versioning and optional parameters

The restrictions on default values for optional parameters may remind you of the restrictions on const fields or attribute values, and they behave very similarly. In both cases, when the compiler references the value, it copies it directly into the output. The generated IL acts exactly as if your original source code had contained the default value. This means if you ever change the default value without recompiling everything that references it, the old callers will still be using the old default value. To make this concrete, imagine this set of steps:

  1. Create a class library  with a class like this:
    public class MyDemo
    {
    	public static void PrintValue(int value = 10)
    	{
    		System.Console.WriteLine(value);
    	}
    }
  2. Create a console application (Application.exe) that references the class library:
    public class Program
    {
    	static void Main()
    	{
    		MyDemo.PrintValue();
    	}
    }
  3. Run the application—it’ll print 10, predictably.
  4. Change the declaration of PrintValue as follows, then recompile just the class library:
    public static void PrintValue(int value = 20)
  5. Rerun the application—it’ll still print 10. The value has been compiled directly into the executable.
  6. Recompile the application and rerun it—this time it’ll print 20.

This versioning issue can cause bugs that are hard to track down, because all the code looks correct. Essentially, you’re restricted to using genuine constants that should never change as default values for optional parameters. There’s one benefit of this setup: it gives the caller a guarantee that the value it knew about at compile-time is the one that’ll be used. Developers may feel more comfortable with that than with a dynamically computed value, or one that depends on the version of the library used at execution time.

Of course, this also means you can’t use any values that can’t be expressed as constants anyway—you can’t create a method with a default value of “the current time,” for example.

Market and Development of Flash Games

Free online game is based on Flash or Shockwave, and in the short future maybe silverlignt based if Microsoft wish. Take this hunting games for example, it is a flash online game. And now, it allows users to access online games through explores, such as IE, FireFox, Chrome and so on. Users can also choose to download his / her discretion in the game for his / her convenience and benefits. These free games, the same instance of a click happy online, because they are after all the hard disk in the user’s system to download.

And you can also play this kind of games using mobile phones, such as your windows phone7. (Can anyone tell me why iPhone don’t support flash!?). At first time, people felt so fascinated tourists witnessed the vast expanse of these games, in his / her selection of the closing of many topics. For this reason, he / she can not resist trying to gain experience at least one game, and eventually agreed to return the number of times, in the passionate pursuit of interactive entertainment faithful. Just give you 2 example games, fashion games, dirt bike games. You will love playing them the time you open it! The video and audio is as fashion as the client games which will take you 1G spaces.

From some statistic, the this market will be very huge. In 2006 the flash games industry revenue was 1.1 billion and it was expected that by 2010 it would reach 4.4 billion. But now it’s expected that it will reach 15 billion $! Will it be exciting?

Developers, don’t hesitate! It is your chance to start developing flash games!

Players,  don’t hesitate! Try something new via trying some flash games!

Performance tuning tips for ASP.NET and IIS 7

1. Browser caching

In part 1, we looked at how it was possible to set an expiration header to any static file such as JavaScript and CSS files, so the browser would cache them for a long time and thereby optimize both for bandwidth and the number of requested files going from server to browser.

The problem with setting a browser cache expiration date of i.e. a JavaScript file to a year in the future becomes clear when you change the file before it expires in your visitor’s browsers. They simply won’t see the changes until they either clear their cache or hits F5 manually.

2. Bundle multiple files

Another common website performance issue is that there are many JavaScript and CSS files included on a page. This scenario results in the browser have to download a lot of extra files and that all slows down the performance of a website. The solution to this is also very simple when you’ve first completed the above steps to register the HTTP handler in web.config and called the BundleHelper.InsertFile method when inserting JavaScript and CSS files.

3. HTTP compression

You’ve always been able to perform HTTP compression in ASP.NET by using third-party libraries or own custom built ones. With IIS 7 you can now throw that away and utilize the build-in compression available from the web.config. Add the following line to enable HTTP compression:

<urlCompression doDynamicCompression=”true” doStaticCompression=”true” dynamicCompressionBeforeCache=”true”/>

By default, only text based content types are compressed.

4. Cache static files

To speed up the load time for the visitors, it is crucial that everything that can be cached by the browser IS cached by the browser. That includes static files such as images, stylesheets and script files. By letting the browser cache all these files means it doesn’t need to request them again for the duration of the cache period. That saves you and your visitors a lot of bandwidth and makes the page load faster. A well primed browser cache also triggers the load and DOMContentLoaded event sooner.

It’s worth noticing that the output caching respects file changes and therefore refreshes ever time changes are made to the JavaScript and CSS files tunnelled through this code.