₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,326,783 members, 8,428,107 topics. Date: Tuesday, 16 June 2026 at 09:43 PM

Toggle theme

Candylips's Posts

Nairaland ForumCandylips's ProfileCandylips's Posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 (of 587 pages)

CareerRe: Electrical Engineering: Aspirants and Practitioners by candylips(m): 1:28am On Aug 14, 2011
elect elect grin
CareerRe: Does GPA Really Matter In The Labour Market? by candylips(m): 8:47am On Aug 12, 2011
Jarus:
With due respect to those with lower degrees - and while not claiming that First and 2.1 automatically mean success - the truth is you stand a greater chance if you make higher classes of degrees than degree.
Not really. you stand a greater chance of success by actively managing your career irrespective of the class of degree.
CareerRe: Does GPA Really Matter In The Labour Market? by candylips(m): 12:35pm On Aug 11, 2011
not really.

At entry level it does matter especially in multinationals

but the emphasis decreases as you gain more experience.

the people running top companies did not necessarily finish with first class or 2.1
ProgrammingRe: Java Coding Challenge: Task Scheduler by candylips(op): 10:09am On Aug 08, 2011
My solution

ExponentialTimer.java

[color=#CCCCCC]package[/color] challenge;

[color=#CCCCCC]import[/color] java.util.Timer;
[color=#CCCCCC]import[/color] java.util.TimerTask;

[color=#808080]/**
* Implements an exponential timer (recursive definition) with a steady state.
*
*
*/
[/color]
[color=#0257ae]public[/color] [color=#0257ae]class[/color] ExponentialTimer
{

    [color=#808080]/*
    * By default, this exponential timer reaches steady state at 900 seconds. (15 mins)
    */
[/color]
    [color=#0257ae]public[/color] [color=#0257ae]static[/color] [color=#0257ae]final[/color] [color=#0257ae]int[/color] DEFAULT_STEADY_STATE_SECONDS = [color=#b0948a]900[/color];

    [color=#0257ae]private[/color] [color=#0257ae]int[/color] steadyStateInSeconds;

    [color=#0257ae]private[/color] Timer timer;

    [color=#0257ae]public[/color] ExponentialTimer()
    {
        steadyStateInSeconds = DEFAULT_STEADY_STATE_SECONDS;

    }

    [color=#0257ae]public[/color] ExponentialTimer([color=#0257ae]int[/color] seconds)
    {
        steadyStateInSeconds = seconds;
    }

    [color=#0257ae]public[/color] [color=#0257ae]void[/color] invoke(Task task)
    {
        scheduleIn(task, [color=#b0948a]1[/color], [color=#b0948a]1[/color]);
    }

    [color=#808080]/**
     * Schedules the timer to invoke the task in the specified delay.
     *
     * @param task
     * @param delay
     * @param retryCount
     */
[/color]
    [color=#0257ae]void[/color] scheduleIn(Task task, [color=#0257ae]long[/color] delay, [color=#0257ae]int[/color] retryCount)
    {
        timer = [color=#FF9D00]new[/color] Timer([color=#b0948a]false[/color]);
        timer.schedule([color=#FF9D00]new[/color] InvokeTaskTimerTask(task, delay, retryCount), delay * [color=#b0948a]1000[/color]);
    }

    [color=#808080]/**
     * If specified, this timer reaches steady state in so many seconds.
     *
     * @param steadyStateInSeconds
     *            the steadyStateInSeconds to set
     */
[/color]
    [color=#0257ae]public[/color] [color=#0257ae]void[/color] setSteadyStateInSeconds([color=#0257ae]int[/color] steadyStateInSeconds)
    {
        [color=#FF9D00]this[/color].steadyStateInSeconds = steadyStateInSeconds;
    }

    [color=#808080]/**
     * Responsible for the retry logic.
     */
[/color]
    [color=#0257ae]class[/color] InvokeTaskTimerTask [color=#0257ae]extends[/color] TimerTask
    {

        [color=#0257ae]private[/color] [color=#0257ae]final[/color] Task task;

        [color=#0257ae]private[/color] [color=#0257ae]final[/color] [color=#0257ae]long[/color] currentDelay;

        [color=#0257ae]private[/color] [color=#0257ae]final[/color] [color=#0257ae]int[/color] retryCount;

        [color=#808080]/**
         * @param task
         */
[/color]
        [color=#0257ae]public[/color] InvokeTaskTimerTask(Task task, [color=#0257ae]long[/color] currentDelay, [color=#0257ae]int[/color] retryCount)
        {
            [color=#FF9D00]this[/color].task = task;
            [color=#FF9D00]this[/color].currentDelay = currentDelay;
            [color=#FF9D00]this[/color].retryCount = retryCount;
        }

        [color=#808080]/**
         * Invoked by the scheduled timer.
         */
[/color]
        @Override
        [color=#0257ae]public[/color] [color=#0257ae]void[/color] run()
        {
            System.out.println([color=#FF0000]"[/color][color=#FF0000]E[/color][color=#FF0000]x[/color][color=#FF0000]e[/color][color=#FF0000]c[/color][color=#FF0000]u[/color][color=#FF0000]t[/color][color=#FF0000]i[/color][color=#FF0000]n[/color][color=#FF0000]g[/color][color=#FF0000] [/color][color=#FF0000]t[/color][color=#FF0000]a[/color][color=#FF0000]s[/color][color=#FF0000]k[/color][color=#FF0000].[/color][color=#FF0000] [/color][color=#FF0000].[/color][color=#FF0000] [/color][color=#FF0000].[/color][color=#FF0000] [/color][color=#FF0000]#[/color][color=#FF0000]"[/color] + retryCount);
            [color=#FF9D00]try[/color]
            {
                task.execute();
                timer.cancel();
            } [color=#FF9D00]catch[/color] (Exception e)
            {
                System.out.println([color=#FF0000]"[/color][color=#FF0000]E[/color][color=#FF0000]r[/color][color=#FF0000]r[/color][color=#FF0000]o[/color][color=#FF0000]r[/color][color=#FF0000] [/color][color=#FF0000]o[/color][color=#FF0000]c[/color][color=#FF0000]c[/color][color=#FF0000]u[/color][color=#FF0000]r[/color][color=#FF0000]r[/color][color=#FF0000]e[/color][color=#FF0000]d[/color][color=#FF0000] [/color][color=#FF0000]w[/color][color=#FF0000]h[/color][color=#FF0000]i[/color][color=#FF0000]l[/color][color=#FF0000]e[/color][color=#FF0000] [/color][color=#FF0000]i[/color][color=#FF0000]n[/color][color=#FF0000]v[/color][color=#FF0000]o[/color][color=#FF0000]k[/color][color=#FF0000]i[/color][color=#FF0000]n[/color][color=#FF0000]g[/color][color=#FF0000] [/color][color=#FF0000]t[/color][color=#FF0000]a[/color][color=#FF0000]s[/color][color=#FF0000]k[/color][color=#FF0000].[/color][color=#FF0000] [/color][color=#FF0000]:[/color][color=#FF0000] [/color][color=#FF0000]"[/color] + e);
            }

            [color=#FF9D00]if[/color] (currentDelay < steadyStateInSeconds)
            {
                [color=#0257ae]long[/color] nextDelay = currentDelay * [color=#b0948a]2[/color] > steadyStateInSeconds ? steadyStateInSeconds : currentDelay * [color=#b0948a]2[/color];
                System.out.println([color=#FF0000]"[/color][color=#FF0000]R[/color][color=#FF0000]e[/color][color=#FF0000]-[/color][color=#FF0000]s[/color][color=#FF0000]c[/color][color=#FF0000]h[/color][color=#FF0000]e[/color][color=#FF0000]d[/color][color=#FF0000]u[/color][color=#FF0000]l[/color][color=#FF0000]i[/color][color=#FF0000]n[/color][color=#FF0000]g[/color][color=#FF0000] [/color][color=#FF0000]t[/color][color=#FF0000]a[/color][color=#FF0000]s[/color][color=#FF0000]k[/color][color=#FF0000] [/color][color=#FF0000]t[/color][color=#FF0000]o[/color][color=#FF0000] [/color][color=#FF0000]r[/color][color=#FF0000]u[/color][color=#FF0000]n[/color][color=#FF0000] [/color][color=#FF0000]i[/color][color=#FF0000]n[/color][color=#FF0000] [/color][color=#FF0000]"[/color] + nextDelay + [color=#FF0000]"[/color][color=#FF0000] [/color][color=#FF0000]s[/color][color=#FF0000]e[/color][color=#FF0000]c[/color][color=#FF0000]o[/color][color=#FF0000]n[/color][color=#FF0000]d[/color][color=#FF0000]s[/color][color=#FF0000]"[/color]);
                scheduleIn(task, nextDelay, retryCount + [color=#b0948a]1[/color]);
            } [color=#FF9D00]else[/color]
            {
                System.out.println(steadyStateInSeconds + [color=#FF0000]"[/color][color=#FF0000] [/color][color=#FF0000]s[/color][color=#FF0000]e[/color][color=#FF0000]c[/color][color=#FF0000]o[/color][color=#FF0000]n[/color][color=#FF0000]d[/color][color=#FF0000]s[/color][color=#FF0000] [/color][color=#FF0000]s[/color][color=#FF0000]t[/color][color=#FF0000]e[/color][color=#FF0000]a[/color][color=#FF0000]d[/color][color=#FF0000]y[/color][color=#FF0000]s[/color][color=#FF0000]t[/color][color=#FF0000]a[/color][color=#FF0000]t[/color][color=#FF0000]e[/color][color=#FF0000] [/color][color=#FF0000]h[/color][color=#FF0000]a[/color][color=#FF0000]s[/color][color=#FF0000] [/color][color=#FF0000]b[/color][color=#FF0000]e[/color][color=#FF0000]e[/color][color=#FF0000]n[/color][color=#FF0000] [/color][color=#FF0000]r[/color][color=#FF0000]e[/color][color=#FF0000]a[/color][color=#FF0000]c[/color][color=#FF0000]h[/color][color=#FF0000]e[/color][color=#FF0000]d[/color][color=#FF0000].[/color][color=#FF0000] [/color][color=#FF0000]T[/color][color=#FF0000]a[/color][color=#FF0000]s[/color][color=#FF0000]k[/color][color=#FF0000] [/color][color=#FF0000]C[/color][color=#FF0000]o[/color][color=#FF0000]m[/color][color=#FF0000]p[/color][color=#FF0000]l[/color][color=#FF0000]e[/color][color=#FF0000]t[/color][color=#FF0000]e[/color][color=#FF0000]d[/color][color=#FF0000]![/color][color=#FF0000]"[/color]);
            }
        }
    }
}


Task.java

[color=#CCCCCC]package[/color] challenge;

[color=#0257ae]public[/color] [color=#0257ae]interface[/color] Task
{

    [color=#0257ae]void[/color] execute();

}



SampleTask.java

[color=#CCCCCC]package[/color] challenge;

[color=#0257ae]public[/color] [color=#0257ae]class[/color] SampleTask [color=#0257ae]implements[/color] Task
{

    @Override
    [color=#0257ae]public[/color] [color=#0257ae]void[/color] execute()
    {
        System.out.println([color=#FF0000]"[/color][color=#FF0000]S[/color][color=#FF0000]u[/color][color=#FF0000]c[/color][color=#FF0000]c[/color][color=#FF0000]e[/color][color=#FF0000]s[/color][color=#FF0000]s[/color][color=#FF0000]f[/color][color=#FF0000]u[/color][color=#FF0000]l[/color][color=#FF0000]l[/color][color=#FF0000]y[/color][color=#FF0000] [/color][color=#FF0000]r[/color][color=#FF0000]a[/color][color=#FF0000]n[/color][color=#FF0000] [/color][color=#FF0000]s[/color][color=#FF0000]a[/color][color=#FF0000]m[/color][color=#FF0000]p[/color][color=#FF0000]l[/color][color=#FF0000]e[/color][color=#FF0000]T[/color][color=#FF0000]a[/color][color=#FF0000]s[/color][color=#FF0000]k[/color][color=#FF0000]![/color][color=#FF0000]"[/color]);

    }

}



TimerMain.java

[color=#CCCCCC]package[/color] challenge;

[color=#0257ae]public[/color] [color=#0257ae]class[/color] TimerMain
{

    [color=#0257ae]public[/color] [color=#0257ae]static[/color] [color=#0257ae]void[/color] main(String[] args) [color=#0257ae]throws[/color] InterruptedException
    {

        ExponentialTimer exponentialTimer = [color=#FF9D00]new[/color] ExponentialTimer([color=#b0948a]8[/color]);
        exponentialTimer.invoke([color=#FF9D00]new[/color] SampleTask());

    }

}



Sample Results


Executing task. . . #1
Successfully ran sampleTask!
Re-scheduling task to run in 2 seconds
Executing task. . . #2
Successfully ran sampleTask!
Re-scheduling task to run in 4 seconds
Executing task. . . #3
Successfully ran sampleTask!
Re-scheduling task to run in 8 seconds
Executing task. . . #4
Successfully ran sampleTask!
8 seconds steadystate has been reached. Task Completed!
ProgrammingRe: Java Coding Challenge: Task Scheduler by candylips(op): 5:57pm On Aug 04, 2011
Great Job !

its looking like you are the only one that will attempt this challenge

Yea i will need the syntax highlighter to post my solution
ProgrammingRe: Java Coding Challenge: Task Scheduler by candylips(op): 4:12pm On Aug 04, 2011
@omo_to_dun

Thats correct i checked the code again i missed the part where you did the bitwise operation interval <<= 1

That effectively gets the expenential of the interval.

Great work !!

Anyone else want  to take  a shot at this before i post my solution   cheesy
CareerRe: Welcome To My Office by candylips(m): 3:00pm On Aug 04, 2011
lol
ProgrammingRe: Java Coding Challenge: Task Scheduler by candylips(op): 9:57am On Aug 04, 2011
very nice try omo_to_dun  grin

You are almost there. The intervals should be 1, 2 ,4 , 8 . . . you can calculate it by taking the square of the current Interval and pass as the next interval to the scheduler

The interface will make the implementation more generic.

I can see in your code that you just increment a taskId as the task.

If you use the interface, it will be possible to execute any logic within the execute method.

Let me give you a hint

public class GenericTask implements Task
{

    @Override
    public void execute()
    {
        System.out.println("Successfully ran genericTask!"wink;

    }

}


In Candylips task just pass in the constructed Generic Task and have it executed in the run method

i.e


public CandyLipsTask(int taskId,Task task)
    {
       this.taskID = taskID;
        this.task = task;
    }


public void run()
    {

        if (taskID == MAX)
            TIMER.cancel();

        task.execute();

        System.err.format("Task %3d : ", taskID);
        System.err.format("%5d seconds have passed after scheduling started.%n",
                ((System.currentTimeMillis() - STARTDATE.getTime()) / 1000));
    }


then in scheduleTask

  timer.schedule(new CandyLipsTask(currentTask++, new GenericTask()), taskStartDate);
ProgrammingRe: Any One Able To Setup Clusters With Cassandra by candylips(m): 11:24pm On Aug 03, 2011
welcome to the NOSQL world. I haven't played with cassandra yet unfortunately but i think there is very good project documentation on apache
ProgrammingRe: Java Coding Challenge: Task Scheduler by candylips(op): 11:20pm On Aug 03, 2011
Fayimora:
[size=15pt]I dnt even understand it in the first place, lol You talking about something like a timer?[/size]
There are two parts to the question.

A scheduler that accepts a task.

A timer that runs this task at exponential time intervals.

So the first time the timer runs the task it will run it for 1 sec.

after the task finishes it should then rerun the task for 2 sec, then 4 sec until it gets to a steady state of 900 secs at which point it can stop.

An example practical use of this is as a simple retry algorithm for reconnecting to a lost database connection. You know typically you might have somewhere in you code that says if you lose db connection try to reconnect. if it fails wait for a few secs and retry again.
CrimeRe: Seun Ajayi Listed Among Uk’s 10 Most Wanted Fraudsters by candylips(m): 8:50pm On Aug 03, 2011
WilWily:
Ajayi is a Yoruba.
Yoruba Lifestyle = Fraudulent Lifestyle
a very idiotic statement
ProgrammingRe: Java Coding Challenge: Task Scheduler by candylips(op): 6:31pm On Aug 03, 2011
anyone good enough to take a shot at this  grin
ProgrammingRe: The Importance Of Software Testing And Not Just Software Programming by candylips(m): 1:54pm On Aug 03, 2011
there is a fundamental reason why defects crop up in the first place. grin

a developer might initialy work on an area of code and then work on it at a latter date probably for a different functionality but inadvently introduce a bug into the old functionality

now typically it is the job of testers is to find this kinds of problems.

what am saying is that if the developer writes an automated test that asserts the functionality of the initial work and then at a latter date introduces a defect because of another work. the moment he runs the automated test he is notified immediately that he has broken old functionality.


IBEXY:
Even in agile, all the players are present (BA, Tester, devloper etc) and work simultheneously.
well some teams are set up in a way whereby everyone is a developer but with different primary skills and secondary skills

so you can have a tester whose primary skill is testing but will be required to help out with BA or coding as required
ProgrammingRe: Help With This Regular Expression: by candylips(m): 12:06pm On Aug 03, 2011
i've had the painful job of integrating with a legacy system that keeps its data in a proprietory data format . .

the only way i could get the data i wanted was to scrap its file for specific patterns.
ProgrammingRe: The Importance Of Software Testing And Not Just Software Programming by candylips(m): 11:49am On Aug 03, 2011
IBEXY:
Testers have never been more relevant. Mind you, testers are not just point and click trouble makers like you want to make out.
ok you are right . testers are still relevant but someone with a sole role for just testing is probably becoming redundant this is because majority of the testing process can be automated if the software is designed properly.

However we still need are people with a flair for testing but also with secondary skills in coding, business analysis etc so that they can make help out in other areas .

in agile methology for example there isn't a "testing phase" per say. testing is integrated with the SDLC so the moment a developer checks in code an army of automated test regress the software and if something is broken they get notified immediately
ProgrammingRe: The Importance Of Software Testing And Not Just Software Programming by candylips(m): 10:42am On Aug 03, 2011
IBEXY:
Custom created Automation scripts themselves are not error free. A human is involved in setting up automation processes too. In the end, manually checking codes before they are unleashed is necessary and will remain indefinitely.
Automation is not God sent end-it-all solution.

Half the tester job adverts on the popular job boards added he word "Manual" in the titles.
what is being automated is whatever a tester will do manually. I will rather trust a computer to do this for me than a human tester.

ofcourse everything can't be fully automated i agree but any redundant part of the system that has a set of boring steps should be handed to the computer to do. .

freeing testers from these boring stuff to do more exploratory testing which they can do manually is more ideal IMHO

they can also spend more time writing more acceptance test covering more scenerios which can then be turned into more automated test.
ProgrammingJava Coding Challenge: Task Scheduler by candylips(op): 10:00am On Aug 03, 2011
Implement a task scheduler that recursively schedules a task for execution at exponential time intervals up to a steady state. (i.e 1,2,4,8,16,32, , 900,900,900 in seconds.) steady state can be any number i.e 900 seconds.


The Task you pass to this scheduler can implement this interface

public interface Task {

void execute() throws Exception;

}
ProgrammingRe: The Importance Of Software Testing And Not Just Software Programming by candylips(m): 9:54am On Aug 03, 2011
what i ment was that manualy regression testing your software everytime you want to release your software is error prone because a human is involved.

for example if a tester is required to test a sequence of steps to assert a functionality. How do i prove with absolute certainty that the tester performed all these steps in the right sequence. i can't . . .

but i can code all the steps and assert the functionality and be absolutely sure that the software was tested
ProgrammingRe: Help With This Regular Expression: by candylips(m): 9:44am On Aug 03, 2011
csv files typically open in excel because of the windows file association.

I think having a good understanding of reg-ex is very important for a developer.

There are many instances where you will need to quickly parse files e.g logs for specific patterns . these types of files will certainly not be in csv format
ProgrammingRe: Functional Programming For Java Programmer Scala Or Clojure? by candylips(m): 9:25am On Aug 03, 2011
Seun:
Scala is worth learning. It's primarily a better Java.
absolutely right. i've been doing scala for a few months now and the elegance of the code is a joy.

Try using IntelliJ IDEA. its scala support is fantastic. Eclipse support is still crap


@Poster

I think in the future systems will be built in multiple languagues.

The reason for this is that as we continue to build more complex systems, doing so elegantly will not be possible in one langugue hence the recent trend towards Polyglot programming

The idea is to use the best languague to solve a specific problem

for example a simple java swing application written in java is stupidly complex. too much boilerplate code

but use Groovy's swing builder and you will develop the same code in 1/4 the lines of code.

So for example you could see the front-end of systems built in groovy, a concurrent server in the back end probably built in clojure or scala and Java handling the data access layer

Since all these langugues run on the JVM you can still build them into a jar file and the JVM doesn't care
Forum GamesRe: ¤¤ I Have A Thing For ¤¤ by candylips(m): 8:54am On Aug 03, 2011
fruit
ProgrammingRe: The Importance Of Software Testing And Not Just Software Programming by candylips(m): 8:59pm On Aug 02, 2011
IBEXY:
Automation might be a God sent but you cannot automate everything. There will still be stuff that needs done manually. Stuff like performance testing can be done automatically. YES. What about visual checks, etc.
it is true . . automatically testing gui functionality can be a pain so u typically need to have someone do it manually

however i have found out that a properly architected and designed code is actually very easy to setup and test automatically.

it typically just involves automating the setting up the environment to a know state, performing the test and asserting the result.


IBEXY:
Again developer bias means tester independence continues to be a large and favourable factor for proper software quality measurement.

Would developers really make good testers of[b] their own code[/b]?
it is not entirely true. what typically happens is that when the tester goes off and start testing independently without collaborating with the developer, they sometimes misinterpret requirements or functionality.

Also manual testing is just error prone especially when you have many moving parts.

the idea behind automated test is to capture whatever a tester will do manually in an automated test and run this whenever the software is built. That way you not only save time you also overtime have a suite of rigorous regression test for your software.

Manual testing however is still essential but i tend to make it important for my team to only manually test  the more complicated stuff that can't be captured automatically
ProgrammingRe: The Importance Of Software Testing And Not Just Software Programming by candylips(m): 3:36pm On Aug 02, 2011
IBEXY:
Most software testers go on to become Business analysts (BA). These people draw up requirements after sitting with business owners.
With more organisations adopting agile methologies like scrum. the role of testers and Business anaylst are becoming irrelevant .

the days of some random BA pushing requirements to developers are numbered.

In agile, business owners and developers sit down define and prioritise requirements and test criteria.

Developers write automated unit, integration, functional and regression tests based on test criteria

in more complex systems some manual testing might be required which migh be done my testers

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 (of 587 pages)