Friday, October 8, 2010

Helpfull UNIX stuff

Find not matches http in files
$ find -xdev -type f -name "*.cs" | while read -r; do file="${REPLY}"; grep -q
'http' "$file" || echo "File '$file' matches"; done


Find
find -xdev -type f -print0 | xargs -r0 egrep -i --files-with-matches 'jdbc\.url'

Test regular expression
egrep -i '^[A-Z]\.?

Find all processes with name java
ps -u -C java

Replace word in group of files
sed 's#oldworld#newworld#g' *.java

Friday, October 1, 2010

Random bash password generation

head /dev/urandom | uuencode -m - | sed -n 2p | cut -c1-${1:-8};

Thursday, September 23, 2010

JAVA vs .NET Development

As far as I had to deal with .NET(popularly called NOT development) would like to publish some notes.
Well as a language .NET is quite good as Java of course if we are talking about the same business usage.
Some violations are cause of architecture desing:

1. interface should start with I - that is good idea for .NET cause it quite difficult understand where is the class where is the interface

public class Test: HibernateDao, Repository

HibernateDao, Repository - the possible combinations are {class,interface} {interface, interface}

2. Namespaces(in Java called package)

namespace PackageName {
public class A1 : AbstractClass, Inreface {}
}

Probably .NET designer thought was the more braces the better code. It's UGLY.
Compare with Java:

package PackageName;
public class A1 extends AbstractClass implements Inreface {}


3.The only thing that is really missed in Java is lambda expressions. But this is the other story. I want to have this option but with a good design, not like it could be post about closures.

4. The main pain in development is the IDE. WTF - was my first thought. Well the times of Turbo C are passed...for such kind development. The IDE is not intuitive and you have to know a lot of tricks how to work with it.

4.1 NUnit execution time - very slow.
4.2 SVN plugin - bugs with adding new item. So manual process.
4.3 ZERO library and dependency management.
4.4 ZERO refactoring support. You have to install additionally Resharper component which is NOT FREE. And it is in the era of AGILE(main artifacts: coding, testing, refactoring, collaboration)

5. ASP.NET MVC2 - is a STRUTS. It's out of box but 21st century outside.And this is the question is it good to have this option out of box or to have modularity like in Java.

Why .NET so popular.
I think the main idea is that because of clicky-clicky development(like embedding files). It became more popular years ago. It was hard to start study J2EE development without studying ANT, Tomcat - additional efforts while .NET had it out of box with samples. Yes JAVA was late in this case only with MAVEN2(2006) this misleading was fixed.

Wednesday, July 7, 2010

Java Closures

Java 7 is going to have lambda expression("closure"). Some people say it's simplification.
Other says no it's harm. Well anonymous classes was a replacement of closures and
as James Gossling says because of time pressure. But the Java culture of programming is formed and
exists a decade. Just try yourself the examples and ask youself:
Is it improve you code? Ask colleges do they understand your code?
Example 1

val SOME 6 =
withReturn
(fn return =>
(app (fn x =>
if 0 = x mod 2 then
return (SOME x)
else
print (Int.toString x))
[1, 3, 5, 6, 7, 9]
; NONE))

What's the result??? It's simple isn't it? 135

Example 2

new Functor(){public Object f(Object x){ ... }}
vs
(lambda (x) ...)
vs
new (){f(x){...}}


Example 3

textField.addActionListner( new ActionListener() {
public void actionPerformed( ActionEvent notUsed ) {
textArea.append( textField.getText() );
}
});
vs
textField.addActionListner( ActionListener()
( notUsed )
textArea.append( textField.getText() );
);

Result: As we see from examples we missing type declaration - so missing the idea
of Java as a language. Simplification of lines of code,lines...No the most for you you IDE
does no matter Eclipse, IntelJ or Netbeans. But if you are a vi or notepad geek just
think maybe it's better for you to write on perl or assembler?


Monday, June 28, 2010

Captcha

http://www.javacodegeeks.com/2010/06/add-captcha-gwt-application.html

Friday, June 25, 2010

GIT+Eclipse

http://wiki.eclipse.org/EGit/User_Guide/Remote#Repository_Selection
http://help.github.com/msysgit-key-setup/

Thursday, May 27, 2010

Modificator for @Autowire

Is it the same?
@Autowired
public indentifier name
@Autowired
private indentifier name

1. Speed issuer. With a private modificator reflection algorith adds only one additional call which is nano seconds time.
name.setAccessible(true);
2. But with a private modificator you don't break object encapsulation