Temat: Próbka kodu a możliwość zatrudnienia
Ta dyskusja pokazała mi jedną rzecz, ludzie którzy mają komercyjne doświadczenie biją na głowę programistów freelancerów. Ale też jest jeszcze jedna rzecz. Ludzie z komercyjnym doświadczeniem nie pracują sami. I to jest już inna sprawa. Pokaże Ci kawałek mojego kodu, sam tylko runner jednej z dużych funkcjonalności, taka super wczesna wersja:
import core.ApplicationRunner;
public class HashingLibrary {
/**
* @param args
*/
public static void main(String[] args) {
ApplicationRunner applicationRunner = new ApplicationRunner();
applicationRunner.runApplication();
}
}
package core;
import registration.RegistrationRunner;
import core.logic.InitializeSoftwareState;
import core.logic.UserDecisionToStart;
import core.ui.SoftwareDecisionFromUser;
import core.ui.SoftwareStateFromUser;
public class ApplicationRunner implements ApplicationRunnable,
SoftwareDecisionFromUserAble,
UserDecideToStartAble,
GetSoftwareStateFromUserAble,
InitializeSoftwareStatable{
boolean setUserDecisionToStart;
@Override
public void runApplication() {
String softwareDecisionFromUser = getSoftwareDecisionFromUser();
if(doesUserDecideToStart(softwareDecisionFromUser) == true){
String passedData = getSoftwareStateFromUser();
String state = initializeSoftwareState(passedData);
softwareStarts(state);
}
else {
System.exit(0);
}
}
private void softwareStarts(String state) {
switch(state){
case "ResgistrationState":
RegistrationRunner registrationRunner = new RegistrationRunner();
registrationRunner.run();
case "QuitState":
System.exit(0);
break;
default:
runApplication();
}
}
@Override
public String getSoftwareDecisionFromUser() {
SoftwareDecisionFromUser softwareDecision = new SoftwareDecisionFromUser();
String softwareDecisionFromUser = softwareDecision.message();
if((softwareDecisionFromUser.equals("Yes") == true) || (softwareDecisionFromUser.equals("No") == true)){
return softwareDecisionFromUser;
}
return null;
}
@Override
public boolean doesUserDecideToStart(String softwareDecisionFromUser) {
if(softwareDecisionFromUser == null){
runApplication();
}
UserDecisionToStart userDecisionToStart = new UserDecisionToStart();
setUserDecisionToStart = userDecisionToStart.whatIsTheDecision(softwareDecisionFromUser);
return setUserDecisionToStart;
}
@Override
public String getSoftwareStateFromUser() {
SoftwareStateFromUser softwareStateFromUser = new SoftwareStateFromUser();
String getSoftwareStateFromUser = softwareStateFromUser.message();
return getSoftwareStateFromUser;
}
@Override
public String initializeSoftwareState(String passedData) {
InitializeSoftwareState initializeSoftwareStatus = new InitializeSoftwareState();
String userPassedData = initializeSoftwareStatus.initializeSoftwareState(passedData);
return userPassedData;
}
}
To jest taki prosty sampel. I przykładowe testy w jUnit:
package core.tests;
import static org.junit.Assert.*;
import org.junit.Test;
import core.ApplicationRunner;
public class ApplicationRunnerTestinitializeSoftwareState {
@Test
public void ApplicationRunnerLoginStateTestTrue() {
ApplicationRunner applicationRunner = new ApplicationRunner();
String enteredValue = "Login";
String expectedValue = "LoginState";
boolean logicValue = true;
assertEquals(logicValue, applicationRunner.initializeSoftwareState(enteredValue).equals(expectedValue));
}
@Test
public void ApplicationRunnerRegistrationStateTestTrue() {
ApplicationRunner applicationRunner = new ApplicationRunner();
String enteredValue = "Registration";
String expectedValue = "RegistrationState";
boolean logicValue = true;
assertEquals(logicValue, applicationRunner.initializeSoftwareState(enteredValue).equals(expectedValue));
}
@Test
public void ApplicationRunnerQuitStateTestTrue() {
ApplicationRunner applicationRunner = new ApplicationRunner();
String enteredValue = "Quit";
String expectedValue = "QuitState";
boolean logicValue = true;
assertEquals(logicValue, applicationRunner.initializeSoftwareState(enteredValue).equals(expectedValue));
}
@Test
public void ApplicationRunnerNullStateTestTrue() {
ApplicationRunner applicationRunner = new ApplicationRunner();
String enteredValue = "Anything or something";
String expectedValue = null;
assertEquals(expectedValue, applicationRunner.initializeSoftwareState(enteredValue));
}
}
package core.tests;
import static org.junit.Assert.*;
import org.junit.Test;
import core.ApplicationRunner;
public class ApplicationRunnerdoesUserDecideToPlaylogicalTests {
@Test
public void doesUserDecideToPlaylogicalYesTestsTrueiSTrue() {
ApplicationRunner applicationRunner = new ApplicationRunner();
String userDecision = "Yes";
boolean expectedValue = true;
assertEquals(expectedValue, applicationRunner.doesUserDecideToStart(userDecision));
}
@Test
public void doesUserDecideToPlaylogicalTestsYesTrueiSFalse() {
ApplicationRunner applicationRunner = new ApplicationRunner();
String userDecision = "Yes";
boolean expectedValue = false;
assertEquals(expectedValue, applicationRunner.doesUserDecideToStart(userDecision));
}
@Test
public void doesUserDecideToPlaylogicalTestsNoFalseiSTrue() {
ApplicationRunner applicationRunner = new ApplicationRunner();
String userDecision = "No";
boolean expectedValue = false;
assertEquals(expectedValue, applicationRunner.doesUserDecideToStart(userDecision));
}
@Test
public void doesUserDecideToPlaylogicalTestsNoTrueiSFalse() {
ApplicationRunner applicationRunner = new ApplicationRunner();
String userDecision = "true";
boolean expectedValue = true;
assertEquals(expectedValue, applicationRunner.doesUserDecideToStart(userDecision));
}
}
To jest tylko szybki neidpracowany sampel majacy oznaczenie 7 na historii rewizji. Soft ma 6 tysiecy rewizji, to jest coś co rozwijam dla kogoś już trochę.