Friday, September 29, 2006

STORY: Junit fails solution and discussion

Our code base is pretty big. It will cost 30 minutes to compile and unit tests, which will not include build the installers. Recently there were always failures happening in the server unit tests. There are two sets of the tests. One will generate the Derby (or java database) and using Hibernate to perform the actual unit tests. The other ones are normal unit tests. They are using mock objects to perform the unit tests. The unit tests will randomly fail due to real DAO and mock DAO problems. All the unit tests will pass if they are run separately.

1) Batch the any test cases inheriting DAOTestCase and batch any test cases inheriting BaseTestCase.

Explanation: Controls how many Java Virtual Machines get created if you want to fork some tests. Possible values are "perTest" (the default), "perBatch" and "once". "once" creates only a single Java VM for all tests while "perTest" creates a new VM for each TestCase class. "perBatch" creates a VM for each nested <batchtest> and one collecting all nested <test>s. Note that only tests with the same settings of filtertrace, haltonerror, haltonfailure, errorproperty and failureproperty can share a VM, so even if you set forkmode to "once", Ant may have to create more than a single Java VM. This attribute is ignored for tests that don't get forked into a new Java VM. since Ant 1.6.2

2) Reduce the test cases which require external database to tests. I look into the many test cases require external database are not actually the DAO classes. In other words, those test cases are not very in high qualities and could be optimized not to use external DB.

Explanation: I agree with your assumption that the tests that aren't the DAO tests that are going against the database are of lower quality and should be corrected so that they are more isolated in their scope. i.e. no database interaction at all. My philosophy is avoid the database at all costs, because it is expensive with respect to time.

3) Introduce JUnit4 which don't require database and hibernate initialization for each test case but for test suites, which will substantially reduce the test time we spend on setting up and tearing down databases and make the unit tests more efficient and shorter time, subsequently less problems.

4) Using memory database for cruise testing and Derby database for daily testing. Rationales are the same as 3).

5) Temporary using forMode="perTest" for stabling current AMT build.

Cons: I realize that from our discussions yesterday that 5) will cost time for the build, but may be a way to bridge the problem as try to correct the root cause. However there is a risk of the "oh its working now, let's not touch it" syndrome sneaking in and stopping us at this stage before we fix what is really going on.

6) Current AMT cruise build is 30 minutes long which definitely drag down the productivity. We should try to reduce the time by multiple means, such as splitting Sentry and Ardmore out of frameworks.

Pros: Yes the 30 minute build is something truly amazing in terms of time. Please, if you find some time, present me with some good arguments for different mechanisms for restructuring the build which could make it more efficient. We can then review them and see what we can do going forward.

Well, as lean software development principles go, we should probably stop and fix this problem now.

So what it comes down to is this, I believe we should be fixing the build, at least to get rid of this recurring problem with the failed tests in the framework. We need to work some more build stories into the iterations, and therefore I believe we have to prepare some compelling arguments with solid goals and at least a rough plan of how to get there to present to management so we can encourage him to "buy" some build improvements.

BLOG: WMI - Windows Management Instrumentation

You could easily management other computers settings thru WMI.

For example, you could easily find out the Events, Remote batch file execution, change the file NTFS setting using “”

Win32_NTEventLogFile

Win32_NTLogEvent

Tools

--+ C:\WINDOWS\SYSTEM32\WBEM\WBEMTEST.EXE

--+ WMI CIM Studio (Downloadable from Microsoft).

Jawin is a great tool to bridge java and WMI and any other windows native dlls.

WMI query is like the SQL query but much simpler than limited functionalities.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wql_sql_for_wmi.asp


WMI Reference

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/wmi_reference.asp

Tony

Wednesday, September 27, 2006

BLOG: Java performance tuning

You can make the JVM start to take the advantage of powerful server config (2+ processor, 2G+ memory)

· java server Xmx1g XX:+UseParallelGC
· increase the size of young generation through put ratio.( 5%). If you want to set the ratio to 5%, you need to calc the milliseconds it needs to set the parameter. The 5% = 1 / (1+nnn). Therefore MaxGCPauseMillis(nnn) equals 19. XX:MaxGCPauseMillis

· -XX:+UseLargePages=2m
· Increase the size of permanent generation
· GC threads will equal to cores
· Client Xshare:on
· -XX:+DisableExplicitGC
· You can use JConsole to connect to agent.

http://java.sun.com/performance/

Tuesday, September 26, 2006

EVENT: Sun Java Developer Day

James Gosling was here to give speech. There are total 4 to 5 million java developers world-wide. Java goes everywhere from enterprise, standard, embedded, and smart card. Java has the database associate with it now which is compatible with SQL 92, 99 and 2003.

There was a splash related to NetBeans. The profiler of NetBeans is really fancy to provide you with heap size, GC statistics, thread count, thread state, per method CPU time, call tree, http monitoring, memory leak. It also has collaboration feature. It also has BluePrints like windows project templates.

The source for Java Technology Collaboration

http://dev.java.net/

Java Specifications

http://jcp.org/

Netbeans

http://netbeans.org/

http://share.java.net/

Tony

REVIEW BOOK: Developing Web Application with ASP.NET and C#

Developing Web Application with ASP.NET and C#

By Hank Meyne, Scott Davis

Overall: ASP .NET is compiled code and running Common Language Runtime. It is truly Object Oriented. It could access the whole Windows System. It has proper error handling. Server-Side controls. It also has state in non-state environment and it is event driven programming.

Anatomy of ASP.NET

<form runat=server> it will generate the hidden input: __VIEWSTATE

<asp:Label>

<asp:Button>

System.Web.UI.Page is the base class of ASP.NET page. .NET package names first letter is Capticalized.

ILDASM.exe to view the .NET MSIL code. (System.Web.dll)

Init Page_Init _Load (attribute PostBack) Unload. _DataBinding, _PreRender _Dispose. _Error

WebForm1.aspx WebForm1.aspx.cs

<%@ Page language=”C#” Codebehind=” WebForm1.aspx.cs”, AutoEventWireup=”false” Inherits=”Chapter2.WrebForm1” %?=> . Codebehind means that base class to be inherited if you have in-line script.

CSC.exe is c-sharp compiler and it will generate .NET assembly and JITed to the x86 native code.

web.config” <compilation>


- Web Server Controls (System.Web.UI.WebControls): Lable, Button, LinkButton, Image, ImageButton, HyperLink, TextBox, Check Box, RodioButton, DropDownList, ListBox, CheckBoxList, RidioButtonList, Panel, Table, (TableRow, TableCell), and DataGrid.


- HTML Server Controls (System.Web.UI.HTMLControls): add form runat=server means any HTML is accessible from the server side.

- ValidationControl (System.Web.UI.Validation). RequiredFieldValidator, RegularExpressionValidator, ValidationSummary, RangeValidator, CompareValidator, CustomValidator (id_ServerValidate)


__doPostBack

<%# %> refers to data binding

Database Access ADO.NET

System.Data.SqlClient Connection, DataSet, Command, DataAdaptor, DataReader (forward only)

System.Web.SessionState

Session.Add(“name”, object). Session[“name”] = object.




Global.asax is the

.ascx file is the ASP.NET Custom Control file.

<%@ Register TagPrefix=”uc1” TagName=”UCCalendar” Src=”UCCalendar.ascx” %>

Chapter 6

Creating more advanced ASP.NET pages

We have seen how to use Web Server Controls and the event-driven programming model that is now available in ASP.NET. Weve covered database access and how we can bind our server-side controls to various data sources. Weve also covered the very useful code-behind programming methodology that allows us to separate the code that makes our page work and the code that makes up user interface.

In this chapter, well introduce some more advanced concepts to build on what we already know. Well cover the HttpRequest, HttpResponse objects, and Cookes and see how we can provide greater customization of client sessions and remember users between visits to our sites. Well also see how we can store our own information in the clients ViewState and store objects in memory on the server-side with Session and Application variables.

Wilson.MasterPages

Web.Config

<appSettings>

<add key="Wilson.MasterPages.DefaultContent" value="mpMainContent" />

<add key="Wilson.MasterPages.TemplateFile" value="~/MainBasicMaster.ascx" />

System.Configuration.ConfigurationSettings.AppSettings[“dsn”]

http://www.microsoft.com/japan/msdn/net/aspnet/aspnet-standardize-masterpages.aspx

http://weblogs.asp.net/pwilson/archive/2004/04/13/112184.aspx

http://wilsondotnet.com/

Global.asax: HttpApplication Object is related to this file.

- Application_Start
- Application_End
- Session_Start
- Session_End
- Application_BeginRequest
- Application_EndRequest

Application Variables are those that are stored on the server and available to all code in the an entire ASP.NET application. This is analogous to a global variable, but used across multiple clients, instead of multiple code modules or windows.

Application[“blah”]

Session is using cookie to store a sessionID. It should have section in the Web.Config to enable Session.

Session[“blah”]

ViewState variables is not kept in the server and has nothing to do with session. Instead, it uses the built-in ViewState mechanism of ASP.Net to store string type date in the hidden View state variables in the browser.

ViewState[“blah”]

Page Subclassing is based on the OO design of the basepage which inherits System.Web.UI.Page.

User Controls provide the ability to reuse user interface code across multiple pages. They provide a simple way to combine multiple Web or HTMl server controls into a reusable web form element that can be place on multiple pages. Navigational or menu bars that are used consistently throughout a web application are prime candidates to be converted to a user control. Prior to ASP.NET this sort of code reuse would have been done through the use of server-side include.

Tony

BLOG: Scrum smells

Signs of something may be amiss on the scrum project:

1. Loss of rhythm.
2. Talking chickens those involved but not committed. Not allowing chicken to talk during the daily meeting is one of the Scrums simple rules.

3. Missing pigs those committed to the project. When run well the daily Scrum should always never exceed fifteen minutes and will always be of value to each pig.

4. Persistence signatures.
5. ScrumMaster assigns work.
6. The daily scrum is for the master. The first purpose of the daily scrum is to provide a coordination mechanism for everyone on the project. The other purpose of the daily Scrum is for each team member to make commitment in front of his or her peers.

7. Specialized job roles. Scrum team need to have a were al lin this together attitude. This can sometimes be undermined if a team has specialized job descriptions or roles.

I am cool on the other way. And here is the other way to think about.

Learn

Perfect

Transcend

People dont like crisis and anxieties. People do things to avoid it instead of dealing with it.

Tony

BLOG: Beyond Agile Software Development: Becoming Lean.

Lean thinking has had a dramatic effect on industries from manufacturing to banking to hospitals. In software development, lean principles lead us inevitably to agile software develop and beyond. Lean is not just about iterative development. It is about transforming customer needs into deployed software rapidly, reliably, and repeatedly.

Lean is not about slowing down and being careful, its about catching errors the moment they occur so that you can reliably go fast.

QA is not responsible for finding defects versus preventing them from happening.

Agile doesnt emphasize speed. Scrum only helps dysfunctional organization.

In queueing theory, Little's result, theorem, or law says: The average number of customers in a stable system (over some time interval) is equal to their average arrival rate, multiplied by their average time in the system. Assume customers arrive at the rate of 10 per hour and stay an average of 0.5 hour. This means we should find the average number of customers in the store at any time to be 5.

Performance is the cycle time how fast the customer needs can be repeatedly convert into the deployed software. Productivity is not how many lines you can write or how many features you can produce over a period of time.

Build only what you need.

Stop when something goes wrong.

Eliminate the waste. (Decide as late as possible. Reduce to-do list. No queues. Small batch. Build quality.)

Amplify the learning.

Optimize as a whole.

Build defects-proof system process, continuous integration and synchronization.


Tony

http://www.poppendieck.com/ (Mary/Tom Poppendieck)

Monday, September 25, 2006

BLOG: SC, NET useful tools in windows.

net use file://10.10.12.176/C$ /u:amsfuturama\ming
sc.exe is very powerful to install and remove services.

BLOG: Text Converting and Intall IIS virtual directory

System.Convert.ToBase64String

System.Convert.FromBase64String

System.Text.Encoding.UTF8.GetBytes(string).

net stop w3svc

net stop iisadmin


Few people realize that files with the .ashx extension are HTTP handlers as well.

How to create the virtual directory in IIS

string strSchema = "IIsWebVirtualDir";

string strRootSubPath = "/W3SVC/1/Root";

DirectoryEntry deRoot = new DirectoryEntry("IIS://" + server + strRootSubPath);

Tony

BLOG: MS SQL Server 2005 Express Edition Requirement:

MS SQL Server 2005 Express Edition Requirement:

Installer SQLEXPR.exe 54M free space.

Require 600MB free space.

- We recommend against running SQL Server Express on a domain controller. it cannot run on a Windows Server 2003 domain controller as Local Service or Network Service

- 2003 Server SP 1 (MSI-3.0)

- Frameworks .NET 2.0 (You could go to %WINDIR%\Microsoft.NET\Framework\ to verify your version).

- To enable the Windows CSP service on Windows Server 2003. (Cryptographic Service Provider)

- MSDTC Is Fully Enabled on Windows

      In Control Panel, open Administrative Tools, and then double-click Component Services.

      In the left pane of Console Root, click Component Services, and then expand Computers.

      Right-click My Computer, and then click Properties.

      On the MSDTC tab, click Security Configuration.

      Under Security Settings, select all of the check boxes.

      Verify that the DTC Logon Account name is set to NT AUTHORITY\NetworkService.

- It install the SQL Native Client and Setup Support Files, MSXML6, SQL VSS Writer, SQL Server Database Services;, Books online.

- Choose Named Instance “SQLExpress”

- Service Account “Local System” probably no network access.

Specifies a domain user account that uses Windows Authentication to set up and connect to SQL Server. Microsoft recommends using a domain user account with minimal rights for the SQL Server service, as the SQL Server service does not require administrator account privileges. The SQL Server Agent account must have administrator privileges if you create CmdExec and ActiveScript jobs that belong to someone other than a SQL Server administrator, or if you use the AutoRestart feature. If the above features are requirements in your environment, consider using separate service accounts for the SQL Server and SQL Server Agent services.

- sa has to be protected with strong password “Avocent456”

- You have to use SQL Server 2005 Surface Area Configuration to open the connection.
- You also need to go to the SQL Server Configuration Manager to set the TCP port to 1433 instead of other value.
-


After you install SQL Server Express, use the following command to connect to SQL Server Express by using the command prompt:

$sqlcmd -S Server\Instance (Kira\SQLExpress)

You could also upgrade from Microsoft SQL Server 2000 Desktop Edition to Express Edition.

Tony

BLOG: NUnit 2.2.8

nunit-gui.exe is useful to attached by the NUNIT test.

nunit-gui.exe /fixture:NUnit.Tests.AssertionTests nunit.tests.dll /run

nunit-gui nunit.tests.csproj /config:Release

You will define the test attributes.

§ Test Fixture
§ Test
§ Setup
§ Teardown
§ Test Fixture SetUp
§ Test Fixture TearDown
§ Expected Exception
§ Category
§ Explicit
§ Suite
§ Ignore


Tony

BLOG: How to install MSDE 2000 Release A

Set up the instanceMode and securityMode, SAPWD, disableNetworkprototal = 0.

setup INSTANCENAME="MSDE" SECURITYMODE=SQL SAPWD="sa" DISABLENETWORKPROTOCOLS=0

Features comparison:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/architec/8_ar_ts_1cdv.asp

Tony

UTF4.0 defines U+FFFF Java String

Counting char Units

private String testString = "abcd\u5B66\uD800\uDF30";
int charCount = testString.length();
System.out.printf("char count: %d\n", charCount);

The length method counts the number of char values in a String object. The sample code prints this:

char count: 7

Counting Character Units

When Unicode version 4.0 defined a significant number of new characters above U+FFFF, the 16-bit char type could no longer represent all characters. Starting with the Java 2 Platform, Standard Edition 5.0 (J2SE 5.0), the Java platform began to support the new Unicode characters as pairs of 16-bit char values called a surrogate pair.

This special use of 16-bit units is called UTF-16, and the Java Platform uses UTF-16 to represent Unicode characters. The char type is now a UTF-16 code unit, not necessarily a complete Unicode character (code point).

private String testString = "abcd\u5B66\uD800\uDF30";
int charCount = testString.length();
int characterCount = testString.codePointCount(0, charCount);
System.out.printf("character count: %d\n", characterCount);

This example prints this:

character count: 6 The Japanese character has Unicode code point U+5B66, which has the same hexadecimal char value \u5B66. The Gothic letter's code point is U+10330. In UTF-16, the Gothic letter is the surrogate pair \uD800\uDF30.

Counting Bytes

byte[] utf8 = null;
int byteCount = 0;
try {
utf8 = str.getBytes("UTF-8");
byteCount = utf8.length;
} catch (UnsupportedEncodingException ex) {
ex.printStackTrace();
}
System.out.printf("UTF-8 Byte Count: %d\n", byteCount);

The target character set determines how many bytes are generated. The UTF-8 encoding transforms a single Unicode code point into one to four 8-bit code units (a byte). The characters a, b, c, and d require a total of only four bytes. The Japanese character turns into three bytes. The Gothic letter takes four bytes. The total result is shown here:

UTF-8 Byte Count: 11


Tony

Thumbs Up to GitHub Copilot and JetBrains Resharper

Having used AI tool GitHub Copilot since 08/16/2023, I’ve realized that learning GitHub Copilot is like learning a new framework or library ...