Arşiv

Posts Tagged ‘Languages’

Good Developer Part 1

30 Ağustos, 2009 burakddd Yorum yapın

Books I Have To Read These Days

17 Ağustos, 2009 burakddd 2 yorum

Spring – I have coming project about open source java ee framework which have very big community and owned by VMware last week.Learning spring not so easy but there is a shortage at market developers who know spring framework good.So there are two books that satisfy my needs about spring framework.One is Spring in action other is spring recipes.

Here are some comments about books i thought it will be usefull.

  • Best overall introduction to Spring 2.0 and higher. Use it with Gary Mak’s Spring Recipes. The chapters on Spring Web Services and Spring Security are alone worth the price of admission.
  • Talk about Injection. This book details how to use it to inject services in your requests. The only way to appreciate spring is if you have implemented or been maintaining code the old way and then see Spring in Action. Its great for injecting anything you can think of in the Application Stack. The only thing I did not appreciate or dont see the need is the Spring MVC but thats my take. I think RIA has Spring eating dust there.
  • The Spring Framework comes with some good documentation, so what does this book offer beyond that? The examples in this book are a bit more fleshed out (though not to the point where you have pages with nothing but code samples), and there are some forays beyond the core Spring Framework (e.g. Spring Security and Spring Modules). It’s well written but don’t expect to find much that isn’t in the free documentation, which is a bit more detailed in general. The biggest issue at the time of the writing of this review is that the book is outdated: The examples may still work, but e.g. Spring MVC has some substantial simplifications in Spring 2.5, and Spring 3.0 is not far off, either, so I’d wait for the 3rd edition of this book.

This is another great book about spring mvc and core,you can find this book very easy to follow also you can read chapters that you are intrested in no connection between chapter examples.

  • This is THE book you should own if you are using Spring. It is organized as cookbook. I refer to it all the time. Very thorough and complete. Of course if you want a good introduction you should read Craig Walls book on Spring If you want to use Spring Web Services or Spring Security in a more than elementary way read the respective reference manuals.
  • I was truly amazed by the ease that the author was able to explain most of Spring’s concepts and functionality. My Kudos to the author.
  • I started with Spring back in 2006 and used the Spring in Action book to get started, which was very good, but this book beats that experience hands down. Gary has done an outstanding job focusing on things that one really needs to know as he/she starts using Spring for serious development. And the explanations are strikingly clear which tells me Gary is a true master of the topic (“If you are not able to explain it in simple language, you probably don’t know it well enough.”). By far the best book on Spring. Thanks Gary.

Collective Intelligence & Recommendation Engines & Machine Learning: This is my own project about recommendation engines i am making early development on these subjects for my project.Actually there is not so much complete resources about these subjects.But there is one known book about these subjects which explain subjects not theorically but with examples that in use.

  • This book gives perhaps the greatest introductory insight into the workings of intelligent algorithmic computation. It covers everything from page rank to neural networks and so much more. Its easy enough to understand, even for a non-math major, and the python code samples are concise, accurate and functional. Would highly recommend this book for application and web developers who are creating or just interested in intelligent, data driven utilities.
  • I’ve had this book for almost a year now, and have been pleased with the content. If you run a website, with users, you probably have a ton of data on how those users use your site. Each chapter covers a different topic in things like search ranking, recommendations (they kind of explain how amazon does it!), plus a ton of other statistical methods and models to help improve your data analysis. The code examples are fairly straight-forward, written in python, and easy to adapt to other programming languages with minimal effort.

Web Development (PHP & MySql & JavaScript ) : My web development side as developer not so good so i decide to strength this side.So i start with most used technologies in web.I know php and mysql at some level but i dont know javascript well .Here are some books can be useful on these techologies.

  • I had the pleasure of being a technical reviewer for the book, and this follow-up to O’Reilly’s Learning PHP & MySQL is an enormous improvement over its predecessors. Robin Nixon maintains a comfortable, conversational tone throughout the text, so newcomers to the topic should not find the material daunting. The contents are very well targeted to novices of the craft, cutting out needless technical details and jargon to focus on what a new developer ought to know to create a functioning website.
  • I’ve only gotten through the first two and a half chapters, but so far it’s a great introduction to the web technologies necessary to make a Web 2.0 site. The author has a great writing style for this kind of book–he is engaging and knowledgeable, while not speaking down at you too much.
  • No programming knowledge is required, and the book does discuss basic concepts like variables, arrays, etc. But it does look like that is all covered in the first few chapters and that by the end you can create working, powerful websites.

Here is another informative book about javascript.Actually i couldnt  start reading this book yet but i will definitly start it .Here are some comments about book.

  • I have had a very wrong notion and understanding of JavaScript until I read this book. This book is a must for serious JavaScript programmers.
  • A fantastically complete reference to Javascript. This is not a “learn Javascript” book, however – but a reference. The examples are not as detailed as in other “learning” books – but as a reference guide it cannot be beat. It is extremely rare that I can’t find what I’m looking for in that book. I am using the 5th edition of the book, which is much better than the older editions – and I feel is the new standard for what should be called a “Definitive Guide”. Pitfalls, quirks, browser differences and a complete (as of 2006 at least) property/function reference for both core and DOM javascript objects. Highly recommended.
  • I bought this book because I wanted to learn JavaScript, and it is doing just that!!! There is so much stuff packed into this book that it is amazing, and I can’t believe I only payed $32 for it! It covers everything you need to know. It goes into more detail about JavaScript than any book on any other language I have seen. And all the pages are not little flashy examples. It is a real reference for those who are serious about learning JS.

Bean Scoping in Spring Framework 2.0

24 Temmuz, 2009 burakddd Yorum yapın

Spring Framework 2.0 comes with new feature called scope of bean.I am using bean as POJO (plane old java object) it doesnt mean that you must use the Java EJB specification in beans , they are just simple java objects.Scope feature comes with version 2.0.Until 2.0 all the beans are default to singelton which is limitating because singelton means one bean object per Spring container.And if you want to change this you must use the singelton property and set it to false.To add more features to Spring , they added the scope attribute to beans.

There are four value of scope property.These are singelton,prototype,session,global session,request.

  • Singelton : as i mention above means that only one bean instance per Spring container.It may sometimes useful but sometimes limitating.
  • Prototype : allow to create more than one instance of the bean(if you request 5 times there are 5 different bean objects in container)
  • Request : Scopes a bean definition to an HTTP request. Only valid when used with a web-capable Spring context (such as with Spring MVC).
  • Session : Scopes a bean definition to an HTTP session. Only valid when used with a web-capable Spring context (such as with Spring MVC).
  • Global -session : Scopes a bean definition to a global HTTP session. Only valid when used in a portlet context.

Burak DEDE

Ceturk Java Etkinliği

28 Haziran, 2009 burakddd Yorum yapın

Bugüne kadar çok farklı konu ve teknoloji ile ilgili yaptığı ücretsiz etkinliklerle sektörünün gelişmesine katkıda bulunan CETURK etkinliklerine devam ediyor.

13 Haziran’da Ankara‘da gerçekleştirilen “CETURK Java Teknoloji Günü-2 – Ankara” etkinliği büyük bir ilgi ile karşılaştı. Gelen yoğun talep üzerine Bu etkinliğin tekrarı 4 Temmuz’da IBM de gerçekleştiriliyor. Etkinlikte Java Teknolojilerinde uzman konuşmacılar bilgilerini katılımcılarla paylaşacaklar. CETURK bu etkinlik ile beraber son bir yılda Java ile ilgili 7. etkinliğini gerçekleştiriyor olacak.

Bu etkinliği IBM Gold Sponsor olarak, i-con Silver sponsor olarak desteklemektedir.

Etkinliğe katılım her zamanki gibi ücretsiz olacak. Ayrıca her zaman olduğu gibi etkinliğe katılan kişilere çekiliş ile kitap hediye edilecek .Etkinliğe katılamayanlar için video kaydı alınarak CETURK.TV ‘de yayınlanacak. Java’ya gönül veren tüm yazılımcıları etkinliğimize bekliyoruz.

Java Swing Part1 : What is Swing ?

14 Haziran, 2009 burakddd 1 yorum
Java (programming language)

What is Swing and Background of Java Foundation Class

Swing is a lightweighht ,platform independent API for creating user interface application with Java.First question to be asked here is what is lightweight and also what is heavyweight ?

Heavyweight gui components are the ones that not require usage of the operating system’s native windowing toolkit.In heavyweight gui  components there is no need to create new component.Heavyweight API use already created operating system components for user interfaces and also by using already created components application gain big performance increase.Heavyweight API’s are AWT and IBM’s SWT.

Lightweight gui components do not use the operating system component hence API draw its own widgets.Swing is one of the examples of the lightweight toolkit.But in performance lightweight toolkits generally are slower that the ones that using operating system own widgets.

For the formal definition of the Swing i got a help of the Wikipedia so here is the answer of what is Swing?

Swing is a widget toolkit for Java. It is part of Sun MicrosystemsJava Foundation Classes (JFC) — an API for providing a graphical user interface (GUI) for Java programs.

Swing was developed to provide a more sophisticated set of GUI components than the earlier Abstract Window Toolkit. Swing provides a native look and feel that emulates the look and feel of several platforms, and also supports a pluggable look and feel that allows applications to have a look and feel unrelated to the underlying platform.

I think thats all background info to learn the Swing.If you want more detalied information you can look at these links.[1],[2],[3],[4],[5],

Burak DEDE

Java Serializable Object by Example

3 Haziran, 2009 burakddd Yorum yapın

Serializing object is a good feature i am sure you have heard in somewhere.It is actually about fields of the object and  saving them for later use.Suppose you have a class Shape that have two instance variable named as width and height of integer type.When you serialize them you actually saving their state , and then de-serialize to their orginal state(by orginal state not to mean  first state when class created , state that variables have before they go into serialization process).Of course to make them serializable you have to use Serializable ınterface.Serializable interface actually different from other kinds of interfaces cause it has no method at all to implement, it just give you the ability to froze state of the object fields and save them and later you can use them for your purposes.When implement serializable interface with class it means that instance variables of that class can save their state.

And What Happen if class not only have primitive field variables also reference variables?

Actually it doesnt change so much thing you have reference to and object in your class as instance variable after serializing object you serializing all the objects that reference refer.So you actually serialize all the object in reference tree.

What Happen if There is a Problem While Serializing Object?

While you serialize all the object in reference tree (mean all the objects that connect each other with references) suppose there is a problem and one of the object serializing process blow up.Then what happen?Does it mean object come with different value back?No .Serializing is “to be or not to be” style process when one of the process blow up all the process blow up other way you have wrong value of the object.Enough background info lets give some example how to read and write object state.Suppose you have 3 objects first,second and third you want to save their state into file like “Game.sv”.Here is what you do…

ObjectOutputStream os=new ObjectOutputStream(new FileOutputStream(“Game.sv”) );
os.writeObject(first);
os.writeObject(second);
os.writeObject(third);
os.close()

Let me explain what happening here.You first give chain to FileOutputStream to help the ObjectOutputStream cause object output stream doesnt have clue about how to handle file.The real job here is object output stream write objects by the help of the file output stream.

What happen while de-serializing the objects(means reading from )?

Actually this is the detailed process of the JVM but it is good to know what happening behind.First of all when you reads objects you get the same state while you serailize them.But how?Simple JVM create object that has exactly same state with the object that serialized.So when reading with object input stream you get object as return value.Lets see a example of it.

ObjectInputStream ois=new ObjectInputStream(new FileInputStream(“Game.sv”));
GameChar firstAfter=(GameChar)ois.readObject();
GameChar secondAfter=(GameChar)ois.readObject();
GameChar thirdAfter=(GameChar)ois.readObject();
//read all objects state back


System.out.println(“First Charater Type was : “+firstAfter.getType());
System.out.println(“Second Character Type was: “+secondAfter.getType());
System.out.println(“Third Character Type was: “+thirdAfter.getType());

Here is you again use object stream but this time input stream and also with file stream.You give the same file name to the program and read in order that you put them.(this is very important).And also if you read more then object you put you get exception error.And print to see if it works corret.I will give complete code below.

This time you can have some question in your mind.Why not we are serailizing hole class?

This is not a good idea in object oriented programming and it is also big overhead.In objects the important and different parts are the fields of that object by serializing hole class you actually holding unnecessary parts of the object,first it seems good but think that you transfering these object through the network and sending hole class will kill the bandwith if you sending a lot object.That why only important part or unique parts of the object is serailizing.Here is the complete code for you to understand suppose you are in rpg game and you want to save your characters (i think it is a best example from real life)

——————————————–Here is the GameChar class——————————————

package com.serial.object;

import java.io.Serializable;

public class GameChar implements Serializable{

/*
* this is a clas  that hold the game characters
* properties  implements serializable interface
* to save the fields of this class’s object
*/
int power;
//hold the power
String type;
//hold type of the character
String [] weapons;
//hold the weapons of the character

public GameChar(int power,String type,String [] weapons){
/*
* 3 argument constructor for
* class
*/
this.power=power;
this.type=type;
this.weapons=weapons;
}

/**
* @return the power
*/
public int getPower() {
return power;
}

/**
* @return the type
*/
public String getType() {
return type;
}

/**
* @return the weapons
*/
public String getWeapons() {
String temp=”";
//get the all weapons into string object
for (int i = 0; i < weapons.length; i++) {
temp+=weapons[i]+” “;
}
return temp;
}

}

—————————————-Here is the GameSave class————————————————-

package com.serial.object;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

import com.sun.corba.se.impl.orbutil.ObjectWriter;

public class GameSave {
/*
* this class is to test if game objects
* fields can be serializable or not
* just test class
*/
public static void main(String[] args) throws ClassNotFoundException {
GameChar first=new GameChar(50,”Elf”,new String [] {“bow”,”sword”,”dust” });
GameChar second=new GameChar(200,”Troll”, new String [] {“bare hand”,”big ax”});
GameChar third=new GameChar(120,”Magician”,new String [] {“spells”,”invisiblity”});

//game chars objects
// now write the objects state to system so that
//user can start where it left
try{
ObjectOutputStream os=new ObjectOutputStream(new FileOutputStream(“Game.sv”) );
os.writeObject(first);
os.writeObject(second);
os.writeObject(third);
os.close();
}catch(IOException e) {
e.printStackTrace();
//print if problem happen while input or output
}
first=null;
second=null;
third=null;
//make them null to not access objects

//lets read object and see if they still got the last values

try{
ObjectInputStream ois=new ObjectInputStream(new FileInputStream(“Game.sv”));
GameChar firstAfter=(GameChar)ois.readObject();
GameChar secondAfter=(GameChar)ois.readObject();
GameChar thirdAfter=(GameChar)ois.readObject();
//read all objects state back

System.out.println(“First Charater Type was : “+firstAfter.getType());
System.out.println(“Second Character Type was: “+secondAfter.getType());
System.out.println(“Third Character Type was: “+thirdAfter.getType());

ois.close();
}catch(IOException ex){
ex.printStackTrace();
//print if problem happens while input ot output
}

}
}

Burak DEDE

How to Set Frame Center of The User Screen

3 Haziran, 2009 burakddd 2 yorum

While working with java swing you want that frame of the project will be centered on the user screen whatever resolution users is using.Here is a code that doing this job for you.

Toolkit toolkit=getToolkit();
Dimension screenSize=toolkit.getScreenSize();
//get the screen size of the host computer by toolkit
setLocation(screenSize.width/2 – getWidth()/2, screenSize.height/2 -getHeight()/2);
//set the frame center of the screen

Categories: java Etiketler:, , , ,

New Version Of Eclipse IDE Galileo

29 Mayıs, 2009 burakddd Yorum yapın

As you know Eclipse is one of the most widely used java ide in java community.The last version of the ide was Ganymede ,when i checked if new version released i found  new release candidate which named Galileo RC1 .You can download it from this link but dont forget its a release candidate for more stable version Ganymede also downloadable if you want follow this link.

Related articles

Compiling Java Packages

27 Mayıs, 2009 burakddd Yorum yapın

Suppose you have a java application which have one package and sub-packages and you have 4 or 5 class to do the implementation of the application and classes have references between each other.In order to compile project you have to make it in specific order but i found more easy way to do this here is code

javac  package/sub-package/*.java

Categories: java Etiketler:, , ,

Writing C Macros-(Preprocessor)

9 Nisan, 2009 burakddd Yorum yapın

As we all know C syntax give programmers a great flexibility while writing code .Some of these flexibilities are  directly accessing memory with pointers,working with bytes and individual bits this list is goes on. There’s also utility in knowing exactly how something works underneath the hood  , this helps a great deal when something you’re trying to do in a higher level language seems way slower than expected.Another intresting part of the C is macro definitions.

At this point we have to understand what preprocessor does.Preprocessor is a program that works before the compilation process and do some operations (especially switching name and substitute text in program).Preprocessor have nothing in common with processor it is totaly different thing.Preprocessor actually program that handles some macros before compiler goes into compilation.Some compilers (or ide )have preprocessor embeded in or works with it.For example Microsoft visual c++,or borland C ide or compilers have preprocessor embeded,on the other side unix type cc or gcc compilers have preprocessor works with  them.

Lets come to the what are macros and how do they work?

#define name     substitute_text

This is a definition of macros which is define.All macros starts with a # sign which indicate that it will handle by the preprocessor(like #include).define macro defines some macro and definition of that macro will be replaced with it.This means important thing that preprocessor does not know anything about c programming syntax ,it has absolutely no idea whats gonna happen after replacement.So that preprocessor dont check any syntax.(can not understand what is if or what is int)so do not put ; sign after definition of macro ends because it is not a C statement.Lets see on example.

#define SIZE 20    /* work on 20 elements */

int data[SIZE];    /* some data */
int twice[SIZE];   /* twice some data */

int main()
{
int index;   /* index into the data */

for (index = 0; index < SIZE; ++index) {
data[index] = index;
twice[index] = index * 2;
}
return (0);

}

Just change the SIZE with 20 where it sees.So if you put any ; sign compiler will give error message on
replacement area not in macro definition.We can understand that preprocessor dont know any C syntax.Also
you can define little function in here(you can define big functions too but it is not a good programming
practice.Another example is

#define MIN(a,b) ((a)>(b)?(b):(a))

Which is another use of macros in C programming defining functions.But as we said earlier this is not a
good programming practice,it makes the source code hard to read because every time you have to go look
top side of the source code.This is first part of the writing macros see you with the second part.Further reading