azizkhani.net

I know that I know nothing

What is a software quality?

clock September 5, 2013 21:12 by author Administrator

Quality(T) = Changeability(T) / Known defects(T)

What can we say about software quality and defects?

  • Software quality is inversely proportion to the number of defects in the system: high quality implies few defects and vice versa
  • Defects have undesirable consequences
  • Defects incur costs, in all likelihood financial costs but there are others, time in particular. Even if defects are not fixed they will incur costs, e.g. over payments from a financial system or people ringing the helpline to report a spelling mistake
  • Removing defects requires rework and rework costs time and money

define “Easy to change”

  • Change is localized
  • Change is less error-prone – perhaps better stated as “change does not inject defect” (Somewhere in Jones writing he suggests 7% of defect fixes inject new defects so high quality software would have a bad fix injection rate less than 7%)
  • Change is more maintainable, i.e. changing software does not detract from the changeability of the software


design pattern

clock June 30, 2013 20:43 by author Administrator

 

  • Don’t use patterns unless you need to.
  • Don’t use patterns that you don’t fully understand.
  • Don’t expect that whoever is going to work on the code in the future to recognize and understand the patterns that you used – stick to common patterns, and make them explicit in comments where you think it is important or necessary.
  • When you’re changing code, take some time to look for and understand the patterns that might be in place, and decide whether it is worth preserving (or restoring) them: whether doing this will really make the code better and more understandable.

ref:http://java.dzone.com/articles/design-patterns-after-design

 



Leadership in Software Development

clock May 19, 2013 21:14 by author Administrator

 

 

Leadership within the software development industry can be a tricky area. All teams require some level of leadership. Promoting members within a team or organization is a practical choice, but skills so highly sought after in development don't always translate into good leadership. Developers are very logical and analytical. In the world of DiSC, which is a behavior assessment tool, most programmers fall into the D (Dominance) or C (Conscientiousness) categories. These individuals are direct, accurate, and task oriented. Although these traits might seem appropriate there are many other facets to leadership. Unfortunately, most individuals are thrust into leadership roles with little experience or guidance. Regardless of the situation, members in leadership roles must take the responsibility seriously. Leadership is a continuous journey of learning, teaching, and growing. Knowing this, how does one gain those abilities?

There are a few standard answers to this question. First, everyone receives the opportunity to learn on the job. Although this method works, the road can be difficult to navigate without a map. Second, ask for book recommendations about leadership. Everyone has at least one favorite they can recommend. Third, find a good mentor. Having a proper mentor is an invaluable resource. Don't be afraid to ask individuals if they have time to sit and talk about leadership. Most don't realize the accommodating nature of mentors. Sometimes they forget that those individuals were once in their shoes.

The last option is the most difficult to achieve because good mentors are hard to find, but there are other avenues. Recently, Chick-fil-A® held their annual Leadercast conference. This one-day event tackles leadership through the knowledge and experience of industry experts and seasoned veterans. One can travel to the actual event or view it at a simulcasted location. The 2013 event featured Jack Welch, Andy Stanley, Coach Mike Krzyzewski, John C. Maxwell, Dr. Henry Cloud, LCDR Rorke Denver, Gold Metal Olympian Sanya Richards-Ross, David Allen, and Condoleezza Rice. The sessions were a rich combination of presentation and interviews. Events like this create a sponging effect where years of knowledge and insight are soaked up. Documentation of each session becomes vital to encourage the flow of information, but still allows time for reflection and maturation. Below are a few highlights from the 2013 event:

"The key in complexity is to see simplicity."
Some also refer to the quote: "Complexity is simplicity done well." These simple references highlight the importance of finding simplicity in each task required.

"You don't need to be the smartest person in the room."
This is an important reminder for leaders. One doesn't need to answer all the questions or always have the best idea. Empower others to make decisions and utilize the outstanding skills of each team member.

"Yesterday is gone... let go of yesterday."
This is a reminder to not let the sins of the past control the future. Mistakes are only bad if they are not used as a tool for learning. Keep a consistent eye on the future.

"Get it out of your head."
Develop a system to keep track of things. This system must be outside of the brain in a notepad or task list. If left in the brain, one will spend either too much time or not enough on each task. The brain excels at tackling one item at a time.

"If everything is important, then nothing is important."
Leaders usually have an overflowing plate of tasks and responsibilities. It's important to have a narrowed focus, while inhibiting everything else. This applies to the team's progress as well.

"Rules don't lead."
Don't attempt to build and enforce rules. Work with teams to devise standards that everyone will hold themselves too. Rules are meant to be broken; standards are meant be exceeded.

 

ref:http://java.dzone.com/articles/leadership-software



Weblogic fast-swap

clock May 17, 2013 22:23 by author Administrator

This is something that could eat up time in any bigger project. If you make changes to your working application and you need to track down bugs, it's inevitable to redeploy your application on any change. What is done in seconds, if you
a) know the WLS administration and/or
b) your application is quite lean

If you have a fullblown JEE application with all the magic inside, it's no problem to wait for a successful redeployment for minutes.
In practice there are some ways to get rid of this overhead very quickly.

1) Weblogic's ChangeAwareClassLoader (WLS <=10.x)
Java classloaders do not have any standard mechanism to undeploy or unload a set of classes, nor can they load new versions of classes. In order to make updates to classes in a running virtual machine, the classloader that loaded the changed classes must be replaced with a new classloader. When a classloader is replaced, all classes that were loaded from that classloader (or any classloaders that are offspring of that classloader) must be reloaded. Any instances of these classes must be re-instantiated. If you deploy an exploded application and run the WLS in development mode, you can take advantage from the ChangeAwareClassloader. If you make changes to a single class, the WLS simply replaces the whole classloader and starts over with your newly created class. This was one of the first approaches to quicker development roundtrips. Anyway it is still not the solution for bigger applications.

2) Weblogic Fast-Swap (WLS >=10.x)
Java EE 5 introduces the ability to redefine a class at runtime without dropping its ClassLoader or abandoning existing instances. This allows containers to reload altered classes without disturbing running applications, vastly speeding up iterative development cycles and improving the overall development and testing experiences. The usefulness of the Java EE dynamic class redefinition is severely curtailed, however, by the restriction that the shape of the class – its declared fields and methods – cannot change. The purpose of FastSwap is to remove this restriction in WLS, allowing the dynamic redefinition of classes with new shapes to facilitate iterative development.

With FastSwap, Java classes are redefined in-place without reloading the ClassLoader, thereby having the decided advantage of fast turnaround times. This means that you do not have to wait for an application to redeploy and then navigate back to wherever you were in the Web page flow. Instead, you can make your changes, auto compile, and then see the effects immediately.
 

    • FastSwap is only supported when WLS is running in development mode. It is automatically disabled in production mode.
    • Only changes to class files in exploded directories are supported. Modifications to class files in archived applications, as well as archived JAR files appearing in the application’s classpath are not supported.


To enable FastSwap in your application, add <fast-swap>true</fast-swap> to the weblogic-application.xml file.

FastSwap can also be enabled for a standalone web-application by adding the <fast-swap> element to the weblogic.xml file.

Once FastSwap is enabled at the descriptor level, an appropriate ClassLoader is instantiated when the application is deployed to WLS. It is recommended that you have your IDE setting set to "compile-on-save" so that java files are compiled on saving. The FastSwap agent tries to find all classes that have been modified since the last iteration by looking at all directories in the classpath.

FastSwap is supported with POJOs (JARs), Web applications (WARs) and enterprise applications (EARs) deployed in an exploded format. FastSwap is not supported with resource adapters (RARs).

 

Supported changes:
    • Addition and Removal of static methods
    • Addition and Removal of instance methods
    • Changes to static and instance method bodies
    • Addition and Removal of static fields
    • Addition and Removal of instance fields
limitations:
    • Java Reflection results do not include newly added fields and methods and include removed fields and methods. As a result, use of the reflection API on the modified classes can result in undesired behavior.
    • Changing the hierarchy of an already existing class is not supported by FastSwap. For example, either a) changing the list of implemented interfaces of a class; or b) changing the superclass of a class, is not supported.
    • Addition or removal of Java annotations is not supported by FastSwap, since this is tied to the reflection changes mentioned above.
    • Addition or removal of methods on EJB Interfaces is not supported by FastSwap since an EJB Compilation step is required to reflect the changes at runtime.
    • Addition or removal of constants from Enums is not supported.
    • Addition or removal of the finalize method is not supported.


When FastSwap is enabled, after you recompile a class, FastSwap attempts to redefine classes in existing classloaders. If redefinition fails because your changes fall outside the scope of supported FastSwap changes, the JVM throws an UnsupportedOperationException in the WLS window and in the server log file. Your application will not reflect the changes, but will continue to run.

ref:http://blog.eisele.net



What is Refactoring?

clock May 17, 2013 20:57 by author Administrator

Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior. Its heart is a series of small behavior preserving transformations. Each transformation (called a 'refactoring') does little, but a sequence of transformations can produce a significant restructuring. Since each refactoring is small, it's less likely to go wrong. The system is also kept fully working after each small refactoring, reducing the chances that a system can get seriously broken during the restructuring.

This is a simple list of refactorings both from the original book and some later sources. Refactorings marked with with have some extra material to what's in the Refactoring book. Refactorings marked with are in addition to those in the refactoring book. Refactorings with Link Only are references to refactorings described elsewhere.

 

 



The generic repository is just a lazy anti-pattern

clock April 18, 2013 19:48 by author Administrator

A generic repository is often used with the entity framework to speed up the process of creating a data layer. In most cases this is a generalization too far and it can be a trap for lazy developers.

A generic repository often looks something like the code below. It defines generic methods for the most common types of data operation, such as updating, fetching and deleting. It’s appealing to developers because it’s simple, flexible and allows you to crank out a large domain model without having to write a lot of code.

public interface IRepository
{
    IEnumerable GetAll();
    IEnumerable Find(Expression> query);
    T GetByID(int id);
    void Add(T item);
    void Update(T item);
    void Delete(T item);
}

The problem is that this is not a neat and convenient abstraction, but rather a time-saving short-cut that can undermine the coherence of a solution in a number of respects.

It’s a leaky abstraction

Martin Fowler defines a repository as an “object that mediates between the domain and data mapping layers”. The objective is to isolate domain objects from details of the data access code.

However, the generic repository can allow developers to wrap the underlying data access technology such as Entity Framework classes. This allows a direct dependency from the data access technology to leak out into the application logic.

A repository should abstract the entire data access layer and enforce the concealment of details such as the database engine or data access technology. This generic implementation does not necessarily isolate anything – it’s just adding a pointless and leaking abstraction with no guaranteed benefits.

It’s too much of a generalization

Most repositories need “Save” and “Delete” methods… well, actually, do they? One objection to the generic repository is that it’s just plain lazy as the developer has not taken the time to consider how any consuming classes will use it. For example, are there any specialized fetch methods you need that may support, say, pagination? Will the repository specialize in reading or updating the model?

Very few real-world domain models can be addressed by the same set of methods. You should consider how you want data to be used. Once you start trying to serve more specialized business requirements then the generic repository quickly starts to look inadequate.

It doesn’t define a meaningful contract

The repository should represent a contract between the domain objects and a data store. It defines the kinds of operations that a data store is expected to service. A weakness of the generic repository is that it defines this contract so widely that it becomes almost meaningless.

The first line of code below illustrates the kind of search method that is often found in generic repositories. It provides a lot of flexibility over how you might query data, but it’s impossible to tell what form of contract this represents. It could be asking the data store to return pretty much anything.

    
IQueryable Find(object query);
    IQueryable FindCustomerByName(string name);

The second line represents something far more concrete. It clearly defines the relationship between domain objects and data store. Apart from the certainty of the contract, it provides a far more readable implementation.

A generic repository does have a place… just not on the frontline

Nobody likes to repeat themselves, but a generic repository interface is an over generalization. That said, there’s nothing to stop you from using a generic repository class as part of a more specific repository implementation. This will help you to derive the re-use benefits of a generic repository whilst still providing a strongly-defined contract.

The code below shows a simple example where a generic Repository<T> class marked for internal access is used within a public-facing repository implementation. This composition approach cuts down on the amount of code you have to write whilst still providing a meaningful public-facing contract.

public class CustomerRepository
{
    private Repository internalRepository;

    public IEnumerable FindCustomerByName(string input)
    {
        return internalRepository.FindBy(c => c.Name == input);
    }
}

A generic repository does have a place, but as a helper rather than a contract. The trick is not to expose a generic interface but achieve re-use through composition.

thanks mohsen salehi for share this post

ref:http://www.ben-morris.com/why-the-generic-repository-is-just-a-lazy-anti-pattern



install weblogic in mac

clock March 24, 2013 21:48 by author Administrator

alis-MacBook-Pro:~ aliakbarazizkhani$  cd /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home
alis-MacBook-Pro:Home aliakbarazizkhani$ sudo mkdir -p jre/lib

WARNING: Improper use of the sudo command could lead to data loss
or the deletion of important system files. Please double-check your
typing when using sudo. Type "man sudo" for more information.

To proceed, enter your password, or type Ctrl-C to abort.

Password:
alis-MacBook-Pro:Home aliakbarazizkhani$ cd jre/lib
alis-MacBook-Pro:lib aliakbarazizkhani$ sudo touch rt.jar
alis-MacBook-Pro:lib aliakbarazizkhani$ sudo touch core.jar
alis-MacBook-Pro:lib aliakbarazizkhani$ cd /azizkhani/software

java -Dspace.detection=false -Dos.name=unix -XX:MaxPermSize=512m -Xmx1024m -jar wls1035_generic.jar



run


export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home

alis-MacBook-Pro:bin aliakbarazizkhani$ export MW_HOME=/azizkhani/Oracle/Middlewarea
alis-MacBook-Pro:bin aliakbarazizkhani$ export USER_MEM_ARGS="-Xmx1024m -XX:MaxPermSize=256m"
alis-MacBook-Pro:bin aliakbarazizkhani$ . /azizkhani/Oracle/Middleware/user_projects/domains/base_domain/bin/setDomainEnv.sh
alis-MacBook-Pro:base_domain aliakbarazizkhani$ . /azizkhani/Oracle/Middleware/user_projects/domains/base_domain/bin/startWeblogic.sh



Bulk fetching with Hibernate

clock March 20, 2013 13:40 by author Administrator


If you need to process large database result sets from Java you can opt for JDBC to give you the low level control required. On the other hand if you are already using an ORM in your application falling back to JDBC might imply some extra pain. You would be losing features such as optimistic locking, caching, automatic fetching when navigating the domain model and so forth. Fortunately most ORMs, like Hibernate, have some options to help you with that. While these techniques are not new, there are a couple of possibilities to choose from.

http://koenserneels.blogspot.be/2013/03/bulk-fetching-with-hibernate.html



kent beck new post

clock March 17, 2013 23:32 by author Administrator
  • point of the "code/code/fix/fix" vs "code/fix/code/fix" question wasn't which is "right", but identifying criteria to use when choosing;

 

  • when the first thing i want to do to address the complexity of a program is write a complexity analyzer, i've gone too inception. just clean;

 

  • they are both expensive, but mutable singletons are way worse than immutable singletons because they create temporal coupling;

 

  • if everyone agrees it's a problem, the fact that you've begun solving it is pretty much all the permission you need


WEBLOGIC BEA-002616: Failed to listen on channel on listenAddress:port

clock February 11, 2013 18:52 by author Administrator

Technology, KeyWords:

WebLogic Server 10.3, Cluster, Exception; Too many open files, Socket, Linux, SLES

Error Message: <BEA-002616> <Failed to listen on channel "Default"…>

 

Problem:

<Critical> <Server> <BEA-002616> <Failed to listen on channel "Default" on IP_NR:Port, failure count: 1, failing for 0 seconds, java.net.SocketException: Too many open files>

 

Description

Weblogic declaration from: http://docs.oracle.com/cd/E23549_01/apirefs.1111/e14397/Server.html

BEA-002616

Critical: Failed to listen on channel "channel" on listenAddress:port, failure count: fails1, failing for secs2 seconds, e3

 

Description

The server listener will retry the listen after a short delay.

 

Cause

The server got an exception while trying to accept client connections. It will try to backoff to aid recovery.

 

Action

The OS limit for the number of open file descriptor (FD limit) needs to be increased. Tune OS parameters that might help the server to accept more client connections (e.g. TCP accept back log).

 

More detail and Background information:

“Tune OS parameters” depends on OS which you use. For Linux, kernel parameters need adjustment- exact details depend on the distribution. There are individual user limits for open files. You can use `ulimit -a` command to find out the Linux for the user that owns.

You can find information regarding the important parameters e.g. number of "open files" or similar entry. Please consider, in AIX, the user limits apply as well as a system OS configuration for the total number of open files allowed on the host.

 

 

Solution

Here is an example how can you check and isolate the position of error.

 

1-    Check linux configuration (e.g. on host XXX):

> ulimit –a

core file size          (blocks, -c) 1

data seg size           (kbytes, -d) unlimited

scheduling priority             (-e) 0

file size               (blocks, -f) unlimited

pending signals                 (-i) 127575

max locked memory       (kbytes, -l) 64

max memory size         (kbytes, -m) 13887980

open files                      (-n) 65600 à OK

pipe size            (512 bytes, -p) 8

POSIX message queues     (bytes, -q) 819200

real-time priority              (-r) 0

stack size              (kbytes, -s) 8192

cpu time               (seconds, -t) unlimited

max user processes              (-u) 127575

virtual memory          (kbytes, -v) 17749200

file locks                      (-x) unlimited

 

The open file descriptor limit is at 65600 as recommended by Oracle.

 

2-    Check currently open files

a.    Find PID of Managed Server

> ps -fea|grep myManagedServer

 

b.    Check open files

Please use lsof (list open files) that lists information about files opened by processes

You see list of open files via (e.g.PID is here 1234)

>lsof -p 1234  

 

In order to findour the number of open files:

> lsof -p 1234 | wc –l

 

In this case, we observed that application has 13 thousand connections on "CLOSE_WAIT" status. This usually happens when the application doesn't close the connections properly:



About the author

 Welcome to this web site . This page has two purposes: Sharing information about my professional life such as articles, presentations, etc.
This website is also a place where I would like to share content I enjoy with the rest of the world. Feel free to take a look around, read my blog


Java,J2EE,Spring Framework,JQuery,

Hibernate,NoSql,Cloud,SOA,Rest WebService and Web Stack tech...

RecentPosts

Month List

Sign In