To confirm uniqueness of column_A x column_B in a table, add unique constraint:
#alter table x add unique ( column_A,column_B )
To see the constraint do:
#show create table;
#desc table;
if you see MUL near a column, this means it is a part of a unique index. keywords: mysql unique constraint column
To remove it:
#show index from modulestepwriteaccess
#DROP index moduleId on modulestepwriteaccess
Search Blog
Friday, October 28, 2016
Thursday, October 27, 2016
A good mybatis cheatsheet
<script>
SELECT * FROM STUDENT
WHERE DEPARTMENT_ID = #{depId}
<if test='joiningDate != null'>
<![CDATA[
AND STUDENT_ID <= #{joiningDate}
]]>
</if>
</script>
Tuesday, October 25, 2016
JSP Eclipse Line Width Format
Window - Preferences - Web - JSP Files - Editor. Click on the link for your kind of JSP (HTML or XML content), and adjust the line width.
Thursday, March 15, 2012
Mercurial Hgweb CGI Windows Apache Howto
1) Apache httpd kurulur
2) mercurial 2.1.1 kurulur
3) python 2.6.6 kurulur
4) http://mercurial.selenic.com/wiki/Download
uzerinden Mercurial-2.1.1 (32-bit py2.6) python library'si kurulur
5) deneme yapmak icin
command prompt ta python de
import mercurial
yaz, calisiyorsa, library yi yukledin demektir.
6) Asagidaki hgweb.cgi yazilir,
apache nin cgi-bin'inine atilir.
#!D:/Python26/python.exe -u
#
# An example hgweb CGI script, edit as necessary
# See also http://mercurial.selenic.com/wiki/PublishingRepositories
# Path to repo or hgweb config to serve (see 'hg help hgweb')
config = "D:\Apache2.2\cgi-bin\hgweb.config"
# Uncomment and adjust if Mercurial is not installed system-wide:
#import sys; sys.path.insert(0, "/path/to/python/lib")
# Uncomment to send python tracebacks to the browser if an error occurs:
import cgitb; cgitb.enable()
from mercurial import demandimport; demandimport.enable()
from mercurial.hgweb import hgweb, wsgicgi
application = hgweb(config)
wsgicgi.launch(application)
7) Yine ayni sekilde cgi-bin'e
hgweb.config dosyasi
[paths]
/Production = D:/repository/JavaMail/*
/WSTest = D:/repository/WSTest/*
[web]
allow_push = *
style = monoblue
contact = xxx.yyy@test.com.ua
push_ssl = false
Atilir.
8) DAha sonra apache'nin config'inde httpd.conf a
ScriptAlias /hg "D:\Apache2.2\cgi-bin\hgweb.cgi"
eklenir.
Redmine Mylyn Connector
Eclipse Side:
1) http://redmin-mylyncon.sourceforge.net/update-site/N/
update-site den burayi ekle ve update et.
2) Bu site cok yardimci oldu
http://thecrumb.com/2011/03/07/installing-redmine-mylyn-connector/
3) Bu directory e gel
C:\Program Files\Bitnami Redmine Stack\apps\redmine\vendor\plugins
4) Git bash tan
git clone git://redmin-mylyncon.git.sourceforge.net/gitroot/redmin-mylyncon/redmine-mylyn-connector
de redmine mylyn connector u yukle
5) webrick'i tekrar calistir
6) administrator ile login ol
8) settings/authentication altindan
enable REST web services checkbox isaretle
Wednesday, February 8, 2012
Software Design Principles
Design Principles
1) Open Close Principle
Means : open for extension, closed for modification.
Bir class'i degistirmek istiyorsan, extend et, degistirme.
Bunun nedeni, backward compatibility, regression testing.
2) Dependency Inversion Principle
Dependency injection, for low coupling, inject the dependency,
instead of creating in your body.
3) Interface Segregation Principle
Interface'in icine sadece gerekli metodlari koy. Fazla koyarsan
gereksiz yere implementor lar, uygulamak zorunda kalir bu metodlari.
4) Single Responsibility Principle.
Eger bir class'in birden cok responsibility'si varsa, o class'i ayirmak lazim.
Ayirmazsak, o class'i bir nedenden dolayi degistirdigimizde, diger
nedenlerden dolayi da degistirmek zorunda kalabiliriz.
5) Liskov's Subtitution Principle
Child class 'in ozellikleri, base class in ozelliklerini bozmayacak.
Yani child class'i istedigimiz zaman base class ile degistirebilmeliyiz.
ve bir sorun yasamamaliyiz
Proxy Pattern ( Structural )
Proxy Pattern ( Structural )
1) Proxy class is used to control access to another class
3) Complex bir objeyi temsil eden basit bir obje olabilir proxy.
Mesela o objenin creation'i expensive ise, onu basit bir obje temsil edebilir.
ve eger cok gerekliyse gercekten yaratilabilir. ( Virtual Proxy )
4) surrogate pattern olarak da bilinir
5)
-> The proxy object has the same interface as the target object
-> The proxy holds a reference to the target object and can forward requests to
the target as required (delegation!)
-> In effect, the proxy object has the authority the act on behalf of the client to
interact with the target object
6) Adapter different interface verir, proxy same interface verir. Decorator
enhanced interface verir.
7) Access controlleri yapan proxy. ( Proctection Proxy )
8)
public interface Graphic {
// a method used to draw the image
public void draw();
}
public class Image implements Graphic {
private byte[] data;
public Image(String filename) {
// Load the image
data = loadImage(filename);
}
public void draw() {
// Draw the image
drawToScreen(data);
}
}
// late initialization, caching
public class ImageProxy implements Graphic {
// Variables to hold the concrete image
private String filename;
private Image content;
public ImageProxy(String filename) {
this.filename = filename;
content = null;
}
// on a draw-request, load the concrete image
// if we haven't done it until yet.
public void draw() {
if (content == null) {
content = new Image(filename);
}
// Forward to the Concrete image.
content.draw();
}
}
9) virtual proxy, firewall proxy, remote proxy, protection proxy etc..
Tuesday, February 7, 2012
Adapter Pattern ( Structural )
Adapter Pattern ( Structural Design Pattern)
1) Adaptee Class : esas obje
Target Interface : Adapter'in implemente edecegi Interface
Adapter Class extends Adaptee implements TargetInterface
2) Elimizdeki objeyi baska bir obje gibi
kullanmak istiyorsak yazdigimiz arac,
adaptor.
Y yi de X gibi kullanmak icin.
Amacin X gibi kullanmak, bu durumda
target interface X
X kapali kutu gibi dusun. Sadece metodlarini
biliyorsun.Ya da degistirmek istemiyorsun X'i, ya da hakkin yok.
Adapter implements X {
member Y; //adaptee
Adapter(Y);
}
main () {
X a = new Adapter(y);
// boylece Y de x gibi oldu.
}
3) Legacy code ya da access olmayan
bir objeyi degistirmemek icin kullanilabilir.
4) Two way adapter, iki interface
implemente etmek gerekiyor.
Sunday, February 5, 2012
SpringMVC Customize DispatcherServlet XML Name
Normalde DispatcherServlet'in mapping
ismi xxx ise, xxx-servlet.xml isimli dosyayi
arar. Eger bunu degistirmek istiyorsak web.xml'e
asagidaki kodu eklemek lazim
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/SpringMVCBeans.xml</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
Spring Prefix For Element Not Bound Hatasi
Eger spring.xml in asagidaki hatayi veriyorsa
<context:component-scan
base-package="com.deploymentplan.server.user.GwtRpcController" />
the prefix "context" for element "context:component-scan" is not bound.
Bu, http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd
xsi:schemaLocation 'a eklenmis fakat xmlns:context="http://www.springframework.org/schema/context" eklenmemis demektir.
Spring MVC DispatcherServlet XML Replacement With Annotation
Spring MVC Controller 2.5.6
1) @Controller and @RequestMapping to replace the XML configuration.
2) Controller artik AbstractController'i extend etmiyor ya da Controller interface'ini implemente etmiyor.
Bunun yerine @Controller yapmamiz yeterli
3) XML icindeki HandlerMapping yapma geregi kalmadi
4) <context:component-scan base-package="com.mkyong.common.controller" />
bu pakette Controller arar.
DAO Design Pattern
DAO Design Pattern
1) DAO layer yaratmamizim sebebi, persistence ile ilgili degistirmek
istedigimiz bir yer varsa, sadece burayi degistirecegiz.
2) domain logic --> persistence mechanism
yerine
domain logic --> DAO's --> persistence mechanism
yapmak.
3) 3 tane sorun var:
a) DAO layer yarattigimiz zaman, connection lari nasil handle edecegiz:
1) Method Scope // iki metod icin iki connection mi olacak ? olmaz
2) Instance Scope // ya birden fazla dao varsa? Connection 'i kim yaratacak ? Kim kapatacak?
3) Thread Scope // ayni dao yu iki farkli thread cagirirsa ne olacak ?
b) Transaction handling de ayni sekilde connection gibi.
c) Exception handling in de dusunulmesi lazim.
4) DAO Manager bu sorunlar konusunda devreye girer.
5) DAOManager butun dao lari cagirir. Single point of access
TDD Test Driven Development
1) TDD : Test Driven Development
first we write the test
1) Write Test
2) Make it fail
3) Write the code
4) Pass the test
5) Refactor
TDD biraz daha yavas. Cunku test
kodlarini da yaziyorsun. Bir de kod stilini
degistirmek lazim.
legacy code ile de TDD yapabilirsin.
Testin yoksa kod degistirmek zor olabilir.
Cok yararli.
2) Genelde en uygun bir feature icin 2 programci calistirmak.
biri test yazarken digeri kodu yaziyor. Fakat management istemez.
3) Bir degisiklikte test kodlarini da tekrar yazmak lazim.
4) Her developer yapmak istemez. Cunku test zevkli gelmeyebilir.
5) Cok disiplinli olmak gerekir, developer'in ne isterse yapmasini engeller. Mocking tool gerekir.
Ilk basta plani bilmiyorsan, yazilan testler anlamsiz olabilir.
6) Her bug'a bir test case yazmak iyi fikir gibi.
7) TDD agile methodology ye cok uygundur. Dokumantasyon vs. olmayan durumlarda
TDD yoksa patlayabilir.
Saturday, February 4, 2012
Set Up SSH Key For Github
Set Up SSH Key For GitHub
1) SSH key daha onceden var mi
$ cd ~/.ssh
eger no such file or directory diyorsa , daha onceden yok.
2) $ ssh-keygen -t rsa -C "xxx@gmail.com"
file ismi sorarsa enter'a bas
passphrase'ini gir enter'a bas.
C:\Documents and Settings\xxx\.ssh
directory sinde id_rsa.pub bizim ssh key'imiz.
3) Account Settings” > Click “SSH Public Keys” > Click “Add another public key”
e key i ekle. hic degistirme, ctrl-a ctrl-c ctrl-v
4) Daha sonra
$ ssh -T git@github.com
yes diyoruz
passphrase yaziyoruz.
ok aliyoruz.
5) bazi tool lar ssh kullanmadan github a connect olur.
bu durumlarda api token kullanmak lazim. Her password degistiriste token da degisir aklinizda olsun
bunu ekle
$ git config --global github.user username
$ git config --global github.token 0123456789yourf0123456789token
Friday, February 3, 2012
Builder Pattern ( Creational )
Builder Pattern
Aşçı elinde tarif varsa pizzayı pisirebilir.
Her tarif bir builder interface.
interface PizzaBuilder
buildSouce()
buildBread()
class HawaiiPizzaBuilder implements PizzaBuilder
Pizza p;
buildSauce(p.buildSauce()) //implementation
buildBread(p.buildBread()) //implementation
class SpicyPizzaBuilder implements PizzaBuilder
Pizza p;
buildSauce(p.buildSauce()) //implementation
buildBread(p.buildBread()) //implementation
class Cook ( Director )
PizzaBuilder pizzaBuilder;
setPizzaBuilder(Pizzabuilder p )
constructPizza(pizzabuilder.buildSauce();pizzabuilder.buildBread();)
getPizza(pizzaBuilder.getPizza())
class BuilderExample {
main() {
Cook cook = new Cook();
PizzaBuilder hpizzabuilder = new HawaiiPizzaBuilder();
cook.setPizzaBuilder(hpizzabuilder);
cook.constructPizza();
cook.getPizza();
}
}
State Pattern (Behavioral)
State Pattern ( Behavioral )
Once State interface'i yaratilir.
Burada her state icin yapilacak davranislari listeleriz
mesela
interface LanguageState
sayNo()
sayYes()
class GermanState implements LanguageState
sayNo() //implementation
sayYes() //implementation
class EnglishState implements LanguageState
sayNo() //implementation
sayYes() //implementation
Simdi state'e sahip olacak class
class Person implements LanguageState // O da LanguageState'i implemente ediyor !
LanguageState ls=null;
setLanguageState(LanguageState s) //implementation
sayNo(return ls.sayNo()) //implementation
sayYes(return ls.sayYes()) //implementation
class Demo
main() {
Person p = new Person()
p.setLanguageState(new GermanState());
p.sayNo();
p.sayYes();
}
Burada state'e gore Person farkli davraniyor. Strategy pattern , online olarak algoritmayi set ediyor.
Yani strategy her zaman bir metod. State Pattern'de, state e gore birden fazla metod'a sahip oluyor.
State pattern de, gercek obje de aslinda bir state oluyor, yukarida LanguageState'i implemente ettigi icin.
Runtime de degisiklige ugradigi icin, buna behavioral pattern deniyor.
Thursday, February 2, 2012
HSQLDB
hsqldb
1) index yok
2) tablo kolonlari ve size lerde limit yok gibi bir sey
3) genelde standalone application lar icin yazildi. Her client a
mysql server kurmamak icin. multi user distributed client system icin
uygun degil.
4) unit test icin kullanilabilir.
Tuesday, January 31, 2012
Cobertura
Cobertura?
Cobertura is a free Java tool that calculates the percentage of code accessed by tests. It can be used to identify which parts of your Java program are lacking test coverage. It is based on jcoverage.
Strategy Pattern ( Behavioral )
Strategy Pattern
1) Policy Pattern olarak da soylenir
2) Pattern
A) Once bir interface ve metodu tanimlanir.
o metod strategy oluyor.
B) strategy'yi implemente eden class
lar yazilir.
C) icinde strategy referansi olan
context class'i yazilir.
D) Daha sonra farkli strategy lerde
context class'ini yaratabiliriz.
3) Class lar sadece behaviour'lari belli
duruma gore degisirse kullanilir.
Subscribe to:
Posts (Atom)