Win a copy of Classic Computer Science Problems in Swift this week in the iOS forum!

salvin francis

+ Follow
since Jan 12, 2009
salvin likes ...
Eclipse IDE Google Web Toolkit Java
Forum Moderator
salvin francis currently moderates these forums:
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Rancher Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by salvin francis

Junilu Lacar wrote:
.. You could also define a private void initWithDefaults() method and call it.

To my taste, I prefer to do all initializations in the constructor itself rather than delegating it all to private method. These are my personal beliefs:
  • To a fellow programmer reading your constructor, all initialization logic is present at one location.
  • If your constructor is getting too huge, it gets noticed at an early stage and raises a code smell that something may be wrong.
  • It makes the constructor logic highly cohesive, i.e. it only does the work of construction with no inclusion of other business logic

  • I am not against calling private methods in constructor, I am simply pointing out that delegating the construction work to a private method may not be good (at least as per my experience)
    4 days ago
    I suggest this :
    5 days ago
    Congratulations to All !!!
    1 week ago
    +cow for that wonderful implementation.
    1 week ago
    Adding to what Campbell has posted, the sum of an arithmetic progression is

    n  x  ( (A1 + An) ÷ 2 )

    n is the total number of elements,
    A1 is the minimum
    An is the maximum

    Our progression has a common difference of 1, hence its easy to calculate n given the min and max :
    n = (An - A1) + 1

    1 week ago
    I think Mano Ag is right.
    2 weeks ago
    I was curious to do this using Streams. My ugly solution:
    Maybe someone can find a better solution to help OP.
    2 weeks ago

    Piet Souris wrote:Or even much easier: ...

    Adding 2 lines to your code more makes it easier to read:

    2 weeks ago

    ras oscar wrote:...Not sure if all the loop structures will accept negative integers?

    Does this solve your doubt ?
    2 weeks ago
    Let me enhance my example to show a more practical explanation:output:
    Hope this helps OP understand the conditional statements better.
    2 weeks ago

    Stephan van Hulst wrote:3. can easily be solved by resetting the branch on the origin server if you have enough permissions to do that, or just revert the commit.

    Agreed, it's not that bad to push and revert with git.

    Stephan van Hulst wrote:4. can be solved by rebasing your commits on top of the correct branch, ...

    Disagree, while rebasing may simply allow the lines to accurately be transferred, functionally, the code has to be still tested. Changes will have to be made to make the rebased copy work. Conflict resolution is more than simply moving lines. Code functionality is equally important.

    Let's say we changed line X in a code within an if condition in Branch A now we simply want to move this to Branch B. A different branch can mean that the if condition itself no longer exists at that location or is refactored into some other method or the class itself does not exist or is renamed, or the package itself is deemed useless !! My personal experience is that refactoring is ugly with conflict resolution. From code point of view, a class name has changed, but from git's point of view, a file has been deleted and another file is added (unless there is an easier way that I do not know about).
    2 weeks ago

    jon ninpoja wrote:will code behave differently?

    Isn't it simple to try it out ?

    Here's my attempt:

    2 weeks ago

    salvin francis wrote:...but here's a clause that's missed by others above ...

    It's rude on my part to simply assume all have missed reading that. I am sorry about that.

    Lakshman Arun wrote:Does it matter here whether a is smaller or larger than b?

    Let me demonstrate with a program:
    2 weeks ago
    Congratulations to all !!!
    Keep up the good work.
    2 weeks ago
    Let me share some software related mistakes :

    1. Before running a delete or update query, ensure that there is a 'where' clause and that you are running the complete query.
         (imagine running:  'delete * from employee' and promptly clicking commit instead of 'delete * from employee where employee_id=1000')
    2. Truncating the wrong table.
    3. The horrors of clicking 'push' in git and then remembering that you didn't test all scenarios.
    4. Working on the wrong branch.................. for weeks !!
    2 weeks ago