Overloading methods that do logically different things, does this break any major principles?

This is something that's been bugging me for a bit now. In some cases you see code that is a series of overloads, but when you look at the actual implementation you realize they do logically different things. However writing them as overloads allows the caller
to ignore this and get the same end result. But would it be more sound to name the methods more explicitly then to write them as overloads?
public void LoadWords(string filePath)
var lines = File.ReadAllLines(filePath).ToList();
LoadWords(lines);
public void LoadWords(IEnumerable<string> words)
// loads words into a List<string> based on some filters
Would these methods better serve future developers to be named as LoadWordsFromFile() and LoadWordsFromEnumerable()?
It seems unnecessary to me, but if that is better what programming principle would apply here?
On the flip side it'd make it so you didn't need to read the signatures to see exactly how you can load the words, which as Uncle Bob says would be a double take. But in general is this type of overloading to be avoided then?

Hi PandoraElite,
>>Would these methods better serve future developers to be named as LoadWordsFromFile() and LoadWordsFromEnumerable()? It seems unnecessary to me, but if that is better what programming principle would apply here?
I think you could define a class with many complex behavior, and the behavior has the same method name with different parameters like below:
//difine the class
public class LoadClass
public void LoadWords(string filePath)
//add method
MessageBox.Show("string");
public void LoadWords(IEnumerable<string> words)
// loads words into a List<string> based on some filters
MessageBox.Show("IEnumerable<string> words");
//use the class
string str = "hello";
List<string> list = new List<string> { "h","e","l","l"};
TestClass.LoadClass loadclass = new TestClass.LoadClass();
loadclass.LoadWords(str);
loadclass.LoadWords(list);
>>On the flip side it'd make it so you didn't need to read the signatures to see exactly how you can load the words, which as Uncle Bob says would be a double take. But in general is this type of overloading to be avoided then?
I think it would be better not to use the “LoadWords(lines)” in the “public void LoadWords(string filePath)”. When you modify the “LoadWords(IEnumerable<string> words”, it would affect the “LoadWords(lines)” method and the function of the “LoadWords(lines)”method
might be effected.
Best Regards,
Edward
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click HERE to participate the survey.

Similar Messages

  • TS4036 my device has been crushed beyond repair, and I don't think I ever did the backup thing. does this mean I can no longer see any of my stuffs??

    my device has been crushed beyond repair, and I don't think I ever did the backup thing. does this mean I can no longer see any of my stuffs??

    thats really 4kd up

  • HT1222 I received message: cannot download, select tools, download only and download manually (something like that). Please help, what does this mean?

    I received message: cannot download, select tools, download only and download manually (something like that). Please help, what does this mean?

    Exactly what it says.
    Do as the message says.

  • My iPhone4 is showing no service so i power down but when i power back up it says to plug into itunes and restore, i had this same issue with another iPhone and apple replaced it but its doing the same thing on this phone any help would be apprecaited

    my iPhone4 is showing no service so i power down but when i power back up it says to plug into itunes and restore, i had this same issue with another iPhone and apple replaced it but its doing the same thing on this phone any help would be apprecaited

    AAAAAANNNNNNDDDDDDD go figure no one can help!!!!! i just dont know what to do, i guess no-one else does either lol!!!! thanks anyway!!!!!

  • I have an iPhone 5 and the camera won't focus. I don't know if there's anything that can be done. Does anyone have any suggestions?

    I have an iPhone 5 and the camera won't focus. I don't know if there's anything that can be done. Does anyone have any suggestions?

    Basic troubleshooting
    reset
    restore with backup
    then as new
    as required if still issues then it is possibly a hardware fault  suggest you take iPhone to an Apple Store genius bar

  • How does this make any sense??

    My husband gets the three bureao FICO subscription....this is on his credit report under "negative factors" HOW does this make ANY sense?!? It has "too many credit accounts with balances" as a negative factor...he has one credit card.... You have too many credit accounts with balances.EquifaxThe FICO® Score considers the number of accounts on a credit report showing a balance.Generally speaking, carrying fewer accounts with balances is considered less risky.For credit cards , your credit report may still show a balance on those cards - even if they are paid off in full each month. The total balance on the last statement is generally the amount that is shown on a credit report. NUMBER OF YOUR ACCOUNTS CARRYING A BALANCE Equifax1 accountFICO High Achievers have an average of 3 credit accounts carrying a balance.

    I think they're trying to say that he doesn't have enough accounts and with only one reporting (with a balance of course), that's their common answer.

  • I can download photos to my computer via my Ipod Touch but not a video of 833mb yet I can send it to my FB account on the same said device, does this make any sense?

    I can download photos to my computer via my Ipod Touch but not a video of 833mb yet I can send it to my FB account on the same said device, does this make any sense?

    See:
    iOS: Importing personal photos and videos from iOS devices to your computer
    Do y have XP? if so see that topic in the above link,
    Can you go to My Computer>iPod>DCIM folder and copy it from there?
    Windows XP can't import video files larger than 500 MB using Camera and Scanner Wizard. You can transfer these files from your device by selecting them in My Computer and dragging or copying the files to your computer's hard drive.

  • If a drive is encrypted (format level) does this mean any un-securely deleted files remain encrypted?

    If a drive is encrypted (at the format level i.e. Journaled Encrypted) does this mean any UN-securely deleted files remain encrypted? Thus empying your trash with secure erase on is redundant?

    I would think the files are safe - while the drive is encrypted.
    I would think once the drive has been unlocked then apps like data rescue may be able to lift previously deleted files from the drive. Might be worth trying it out.....
    I think with an encrypted drive, all bets are off once the key is entered, it would appear as any other drive at that stage.

  • I'm thinking of using Final Cut Pro to straighten slightly crooked footage and then re-import back to iMovie to complete the video. Does this have any impact on image quality?

    I'm thinking of using Final Cut Pro to straighten slightly crooked footage and then re-import back to iMovie to complete the video. Does this have any impact on image quality?

    As your rotate the image, you will begin to see black edges. So, as Tom implies, the image must be scaled up to hide those voids. If you shot 4k ad are editing in a HD timeline, no problem, lots of room to spare. If you shot 1080 and are editing in a 1080 timeline, you will run into issues at a certain point. However, if your 1080 project is going to be transcoded to 720 or ye olde DVD you won't notice any deterioration at all.

  • My iPad2 seems to be sending gobs of emails to the addressee, but I only wanted to send 1copy.  It's almost as if a virus is doing this!  Any suggestions?

    My iPad2 seems to be sending gobs of emails to the addressee, but I only wanted to send 1 copy.  It's almost as if a virus is doing this!  Any suggestions?

    My iPad2 seems to be sending gobs of emails to the addressee, but I only wanted to send 1 copy.  It's almost as if a virus is doing this!  Any suggestions?

  • I have Mac OS X version 10.7.3 Does this have any numbers or excel like programs or will I need to purchase them?

    I have Mac OS X version 10.7.3 Does this have any numbers or excel like programs or will I need to purchase them?

    Hi Linda...
    You can purchase Numbers from the App Store.
    You can launch the App Store from your Apple menu > App Store
    Or from your Dock >
    Or from your Applications folder.

  • HT2731 How do I enrol in iTunes u? It asks for a code and I don't no what that means and my iPod does this wierd thing!....

    Hey I need help in enrollment on iTunes u I already did my appleID but then it asks for a code and idk what that is. Btw I need iTunes u to catch up in school cuz some things I'm bad at and I tried diff. Things in school and it didn't work so I'm trying this out, school has just begun... It would b totally awesome if some1 could get back to me on this plz email me at [email protected]..........and I also have troubles with my iPod touch 4g, when I'm searching things on the google app my iPods screen turns black for 5 seconds then goes to the home screen and it does this every time I'm in the google app and sometimes it does this when I'm playing a game or looking on iTunes plz help me!!!! P.s I won't b on here very much so if you have an answer for me email me :) at [email protected]      :) :)

    I am using MAC OSx 10.5.8 (9L31a) as my operation system.  The TV says "No signal.  Check connected device's power, cable connection and source selection."  Seems to me that that goes in hand with what the Samsung tech said about the Mac needing to be forces to use the external display.  But how do I do that?

  • CC Photography Programme - Does this make any commercial sense?

    This seems crazy economics from Adobe. Because I am an educator you offered me and I accepted a reduced price on Photoshop. This wasn't because you value my work with young people it was because I might open their eyes to Adobe products. Now because of this you won't let me buy the CC Photography Programme subscription. I and many other would have bought the original subscription offer if we could afford it. Clearly only about 700K users could do so until recently. Now you offer the CC PP as a 'reward' to existing customers. You don't have to go to Harvard BS to know that in retail there are no rewards, only incentives disguised as rewards. You want as many people as possible to sign up. It matters not one bit what anyone did, had or bought before. All that matters is what they WILL spend and for how long. I want to subscribe, I want to give you $9..99 a month, every month until I die or go blind. You won't let me do that and my only other alternative is to walk away. Adobe is turning profit away for no good reason. PLEASE if anyone reading this has any power to influence, try to convening marketing not to turn good loyal customers' money away. For Adobe it may not add up to a whole hill of beans but every little helps.

    As "Beverly (Adobe staff)" states here, are you part of the automatic migration? Or maybe it does not apply to educational offers?
    http://forums.adobe.com/message/5698957

  • HT1918 despite changing my apple twice id somebody in N. America/Canada is downloading games from my account. the website does not give me any recourse to correct this and track who is doing this. Any suggestion would be gratefully received

    Hi,
    I cannot seem to find any help for a situation that has now occurred twice, despite changing my apple id on bith occasions. Twice now, once from Canada, the second time from the USA, someone has downloaded games using my account.
    The website seems particularly unhelpful as to how to rectify this and Apple do not appear to want to take responsibility for helping me sort this out. any suggestions would be gratefull received.

    Hi aughton880,
    To address your immediate issue, for any purchases you did not make I would report by following these instructions:
    How to report an issue with your iTunes Store, App Store, Mac App Store, or iBookstore purchase
    http://support.apple.com/kb/ht1933
    Two step authentication may be a good security measure to add to your account to prevent future issues:
    Apple ID: Frequently asked questions about two-step verification for Apple ID
    http://support.apple.com/kb/HT5570
    I would recommend changing your password as well:
    Apple ID: Changing your Apple ID password
    http://support.apple.com/kb/HT5624
    I hope this helps!
    - Ari

  • I Need Help i have no idea how to fix this issue, but basically i bought my iphone 4 from amazon and i factory reset it and put the 02 simcard that it required, then once doing this im now stuck at the activation screen as it says "please put the appleID"

    Where do i go from here i do not know what to do as i have been trying to contact the person i bought it from but they have given me no reply i need advice on how to get this problem solved, i do have the email confirmation is that enough to get apple to deactivate it from the persons Icloud

    Until that person help you, the iPhone is a dead weight. We can't help you with this. This is the new activation lock feature to prevent stolen iPhone from activating.

Maybe you are looking for

  • Java en Vista (compatibility)

    Are there any recent articles/websites about compatibility between Java and Vista, Especially older versions of the JRE, like 1.4.x and 1.5.x ? I found http://weblogs.java.net/blog/chet/archive/2006/10/java_on_vista_y.html Or is anyone here working o

  • How can I use layer axis versus world axis to animate?

    Hi all, I'm open to alternate ways to approach this. I'm trying to create a sphere using several images. Say, 200 images, arranged in 3d space so they face outwards and are all forming one large sphere. Pretty standard thing (like the glowing blue dr

  • Trouble installing Adobe Presenter 8...

    Hello ... I am having trouble installing Adobe Presenter8.  I downloaded everything to my desktop, and when I run the installer, it installs 2%, then I get the error code that I attached...  its in German, but it just says an error occured during ins

  • Interface in Business object(swo1)

    HI All, Can anybody kindly explain me what is INTERFACE and ATTRIBUTES in business object(SWO1). Also kindly guide how does it works. Thanks, Sanjay

  • Enforcing Retention Policy

    I have been asked by the head of the organization to enforce a 30 day retention policy for ALL emails in everyone's Outlook (Exchange 2010) - Inbox, Sent, Deleted, etc. (he deletes EVERY message as soon as he read it).    So I went into the EMC and f