.net - Indirection Introduced By Interfaces And Factories Affect Performance?
Apr 15, 2011
I would like to improve testability of some legacy code. To achieve this, I am introducing interfaces for existing classes (and have existing classes implement those) and factories that create an instance of a test object or an object of the original class, depending on some configuration setting.I can foresee some internal feedback along the lines of 'but this will affect performance', but I would like to be able to test some code (for a service layer in this case), without having to deploy all underlying layers and setup a database server.Do you have any experience where the indirection introduced did affect performance noticeably? What would be a constructive way to respond to the aforementioned feedback?
View 2 Replies
ADVERTISEMENT
Aug 20, 2010
I would like to improve testability of some legacy code. To achieve this, I am introducing interfaces for existing classes (and have existing classes implement those) and factories that create an instance of a test object or an object of the original class, depending on some configuration setting.
I can foresee some internal feedback along the lines of 'but this will affect performance', but I would like to be able to test some code (for a service layer in this case), without having to deploy all underlying layers and setup a database server. Do you have any experience where the indirection introduced did affect performance noticeably? What would be a constructive way to respond to the aforementioned feedback?
View 3 Replies
Jan 30, 2009
Anyone able to advise me ? (I'm NOT a c programmer by any stretch). C typedefs:
[Code]...
View 1 Replies
Apr 4, 2012
I remember with InterSystems Cache code, you can use indirection to take a string and turn that into real executable code by preceding the string variable with "@". Can this be done in C#.NET or VB.NET code? So I'd like to have a method that would take an arguments array of strings (with one or multiple lines of code), and run that code, assuming it doesn't throw an exception of course. Where am I going with this? I'm trying to write a compiler within .NET code.
SET x="set a=3" XECUTE x ; sets the public variable a to 3
OR SET x="tag1" d @x ; do/call the public subroutine tag1
OR Set Y = "B",@Y = 6 ; sets public variable B = 6
View 2 Replies
Oct 23, 2008
I'm using visual studio 2008 and creating a Windows For Application.
I'm almost completed my little application and what I've discovered just recently is that any change I made is not taking affect.
What I mean is if I change the display name of a button or insert a msgbox popup, it doesnt make it to the build when I run it. There are no errorswarnings.
View 3 Replies
Mar 1, 2011
Private procQueue1 As New Queue(Of c_proc)
..
..
..
Private Sub updateQueue(ByVal num As Integer)
[Code]....
If I make changes to pq will they affect procQueue1?
View 3 Replies
Apr 15, 2011
I'm going to create some command line tools that make use of some large library DLL's. For security reasons I plan to embed the DLL's in the command line's EXE. Example:Suppose the CL's (command line tool) functionality is to just copy a file from A to B. The procedure to do this is included in a 100MB library DLL. If I would just take out the lines of code from the DLL and paste them in the CL's code then the CL would only be 10Kb.But I don't want to do that, so I embed the full library in the CL's EXE, which will make it 101MB in size.I once read somewhere (cannot remember where) that Windows would only use the part of the EXE that's actually used. So if that's true then it shouldn't matter if the EXE size is 10Kb, 100MB or 1GB.I own the code of the DLL, so if the best solution is to not include the whole DLL but just only link to or include those code files, of the DLL project, that are used by the CL then I will go that way.will the 10Kb CL run faster and consume less memory than the 101MB CL?
View 2 Replies
Jun 7, 2011
I have a simple 'Working' form that runs on its own thread to keep the user informed that the application hasn't died during long running operations. In order to get the working form to update I had to insert a DoEvents() call. I'm curious, will this only pump messages for the current thread I'm in, or will it do it for the whole application? I would prefer that the main window stay unresponsive till the operation finishes. Just to be clear, I'm fine with the code I have, but I would like to know how DoEvents() behaves with threads.
Below is the code for the working form.
Public Class frmWorking
''' <summary>
''' Creates and starts a new thread to handle the Working Dialog
''' </summary>
''' <returns>The thread of the Working dialog.</returns>
[Code] .....
View 2 Replies
Jul 27, 2011
config files, or dll.config for a class library project (dll). Does the dll have to be compiled for the changes in the config file to take affect?The problem I've noticed is that I add a reference to another solution to my dll, and it still has a connection string that points to the test database, even though I've updated it in the config file.
View 3 Replies
May 21, 2012
I am using a Checkbox outside of a datagrid. When i select the check box autopostback is true, and this would then show the image, but i cant access the images within the datagrid with that script. If i use a seperate image outside of the datagrid the script works. How can i get this script to work finding when the checkbox out side of the datagrid is checked to then show the image within the datagrid?
The script i am using is
<script runat="server">
Sub Check(sender As Object, e As EventArgs)
[code].....
View 2 Replies
Apr 26, 2012
I am COMPLETELY new to Visual Basic except for a high school Computer Programming class and I'm attempting to make a text-based game via VB2008. There is a tough problem I'm having. I followed a few YouTube tutorials and managed to create something where you can press a button and have a window open where you search for a text file and have it's file path appear in a text box. My problem now is that I want certain lines of this text file to change the text of certain Labels on a different form. I don't know how to do this though?
View 11 Replies
Jan 11, 2012
What does Windows do to an app when it is run in Compatibility Mode?Is there a way I can detect the compatibility mode settings in .NET?
View 1 Replies
Mar 10, 2009
I have a project that has several combo boxes on one form. The selection in a box can affect the possible choices in subsequent boxes. Right now I am using SelectedValueChange to fire the code that loads the choices in the later boxes. There are a number of possible events that I could use:SelectedIndexChangedLeaveLostFocusTextChangedI was wondering if someone could give me a rough idea what the differences are between these. Is there a 'best' evnet to use?Also, I find that most events work when the choice is made with a mouse click but if you click in the box and type in a value an event does not fire. How can I program for the case where the user enters a value by typing it in instead of choosing from the drop down list?
View 3 Replies
May 7, 2012
I have an app that reads a directory to get the filenames in a directory for each File in Directory(process file) next file. I want to know if the file size makes a difference to the time it takes to get the filenames.eg if a folder contains 10,000 photos of 1 megapixel and another has a folder of 10,000 photos of 8 megapixels will it take the same time.
View 1 Replies
Jan 27, 2010
Does a the size of the class affect the memory usage of the application? is it better to break big classes into smaller classes or just group them up into one big class.
View 2 Replies
Apr 15, 2012
I've only used type inference when using LINQ in VB.NET. However, I'm aware that type inference can be used in other parts of the language, as demonstrated below:
Dim i = 1 'i is inferred to be an Integer
Dim s = "Hoi" 's is inferred to be a string
Dim Temperatures(10) as Double
[code]....
I can see how type inference reduces the amount of typing I would need to write a piece of code and can also make it quicker to change the type of a base variable (such as Temperatures(10) above) as you wouldn't need to change the types of all other variables that access it (such as T). However, I was concerned that the lack of an explicit declaration of type might make the code harder to read, say during a code inspection, as it may not be immediately obvious what type a variable is. For example, by looking at just the For loop above, you might correclty assume that T is some floating point value, but wouldn't be able to tell if it's single- or double-precision without looking back at the declaration of Temperatures. Depending on how the code is written, Temperatures could be declared much earlier and would thus require the reader to go back and find the declaration and then resume reading. Admittedly, when using a good IDE, this is not so much of an issue, as a quick hover of the mouse cursor over the variable name reveals the type.
Also, I would imagine that using type inference in some situations could introduce some bugs when attempting to change the code. Consider the following (admittedly contrived) example, assuming that the classes A and B do completely different things.
Class A
Public Sub DoSomething()
End Sub
End Class
[code]....
It is possible to change the type of ObjectList from A to B and the code would compile, but would function differently, which could manifest as a bug in other parts of the code.With some examples of type inference, I would imagine that most people would agree that its use has no negative affect on readability or maintainability. For example, in Java 7, the following can be used:
ArrayList<String> a = new ArrayList<>(); // The constructor type is inferred from the declaration.
instead of
ArrayList<String> a = new ArrayList<String>();
View 3 Replies
Jul 19, 2009
i created a custom control that accepts only datetime values. [url] but i'm having some issues with it when it is bound to a column and then i navigate through records. it seems to trigger a row-change to all navigated records even though i haven't manually change anything on these records.
this is affecting the last_update_date and last_updated_by fields of my tables. i need to only affect records that were manually changed. can anyone help me? also, any date field should be bound to the Value property of this control instead of Text. haven't figured out how to remove the Text from bindable properties yet.
View 7 Replies
Oct 16, 2009
Are Interfaces used often? Need opinions.
View 4 Replies
Mar 13, 2009
I have the following problem with MEF: Interface definition to be used by host:
Public Interface IExecuteDoSomething
Inherits IAddinSettings
Event DataReceived As EventHandler(Of DataReceivedEventArgs)
Function DoSomething() As Boolean
End Interface
[Code]...
Everything seems to work fine until the Button2_Click routine is executed, then an InvalidCastException is thrown with the info:Unable to cast object of type 'System.Collections.Generic.List1[SharedLibrary.IExecuteDoSomething]' to type 'System.Collections.Generic.List1[SharedLibrary.IAddinSettings]'.
How can i solve this problem, because the imported object implements both of the interfaces?
View 1 Replies
Dec 30, 2011
In this discussion let us discuss every usage of interfaces in .NET. Any real time examples and difficulties in using interfaces can also be discussed here.
View 6 Replies
Aug 6, 2009
Im building a game with VB.NET I designed the core of the game in form1 window But now I need menus. How can I implement this without having 5 or so windows that I show() and hide() ? Doing that slows it down a lot and uses lots of memory. I tried tabs, but I don't want the tabs to appear, just switch. Whats the best way to implement multiple interfaces?
View 1 Replies
Jul 14, 2011
Has someone a hint what I'm doing wrong in VB.Net?
Module Module1
Interface ISearch(Of T As ISearchResult)
Function ids() As List(Of T)
End Interface
[CODE]...
The third cast isn't working. Why? did I miss a oop lesson?
View 2 Replies
Sep 12, 2009
What I would like to do is make an abstract class that will hold objects in a dictionary and manage the adding/deleting/key changes of those items in the dictionary. My problem is that in order to make the class as generic as possible I declared the dictionary as dictionary(of long, of SomeInterface).The problem is when I try to pass a strongly typed dictionary in the constructor using dictionary( of long, ClassThatImplementsSomeInterface) I get a compiler error because it cannot convert to that type.
The reason I want to pass the dictionary in the abstract class's constructor is so that I can use the strongly typed dictionary in the subclass and have the abstract class manage the keys when it needs to. So how can I do something like this? Also- If there is a much better way to manage keys than what I am doing feel free to let me know, but I am much more interested in how to make this work since I have encountered this type of problem a few times before.
Here's the abstract class:
Public MustInherit Class HasChildrenKeys
Protected m_childItems As Dictionary(Of Long, IHasKey)
[code].....
View 7 Replies
Oct 20, 2011
I have a solution with multiple projects, some of the projects are written in VB, some in C#. I am wondering if there's a way to use interfaces and/or enums written in VB in C# classes? My C# code below doesn't compile, however I am able to see the interface in intellisense.
[Code]...
P.S It's a console/service application, not ASP.Net (where I know it's doable).UPD: Sorry guys, was missing a reference to the project with the interface. It's fixed now. I think the thing that in VB projects references are done slightly different than in C# confused me.
View 2 Replies
May 1, 2009
I have a program written in Visual Studio to me 3 values ( 0-255, 0-255, 0-255) to send the serial interfaces, and While assigned to the 3 values of 3 sliders together.[code...]
View 1 Replies
Nov 14, 2010
Say I have a interface called IProperties and I have a collection called colMyProperties that is a collection of IProperties. Then I have an object called clsProperty that implements the IProperty interface. Now, in my code where I add objects to the colMyProperties collection I add a bunch of clsProperty objects. so far so good.
Now when I try to access an object in the collection I can only access properties and methods of the IProperties interface, not the clsProperty object. What am I doing wrong? Do I need to cast the object?
View 2 Replies
Oct 4, 2011
I have a project that has several different interfaces (a website, a local application, and some webservices), that all use the same class library. The library is an API to a database. Some settings, like log level, database connection etc, i want to store in a single place, and I want them editable. What is the best way to accomplish this? I am concerned both about ease of editing, and ease of access for the dll, as there will be a lot of calls to it and a lot of lookups for the values. I have considered using app.config, a standalone XML file, and writing values to the registry, but I cannot find any good comparisons.
View 2 Replies
Dec 8, 2009
I have three classes which implement an Interface iComparesWith, and I wish there to be a single function such that each iComparesWith object of any of the three implementing classes should be able to compare itself with any other iComparesWith object, again, of any of the three implementing classes, and know if the two objects are equal. How can I code this so that the comparison code is only written once? Is it the case that I will have to create a top-level MustInherit class which implements the equality comparison, and have MustOverride methods for all of the methods of iComparesWith?
View 1 Replies
Jul 5, 2010
I am working on creating a customized UI composite control. This control would be a container to several other custom controls.As a first step, i am creating the container UI using a singleton pattern. This is because at any point in time only one isntance of this container is allowed to be created. This is fine.Now i want to practice interface based desgin. So i introduced a sinple interface calleD IdesignSurface which has two properties. I would like my singleton class to implement this interface,so i tried something like this and got an error saying "end of line
NotInheritable
Class DesignSurface
implements IDesignSurface
[code]......
View 2 Replies
Aug 25, 2011
I am a VB programmer of some 13 years. I started briefly with VB5 back in the mid-to-late 1990s, but then quickly moved to VB6 which I did for several years on PCs and HPCs (CE 1.x devices).I have done .NET 2002, 2003, 2005, and 2008 each for stints, intermingled with VB6 coding, at various jobs. But, I never got formally trained on VB.NET. In fact, I taught myself VB5/6 too. I have a degree in Computer Science and Mathematics, but the university CS program only had Unix systems. I basically learned everything I know on the fly from various Microsoft Press and other company's books (and the MS website/MSDN CDs too) while doing projects.I was wondering what everyone would suggest to really learn the .NET workings and why they are setup like that for Windows client/server applications. It doesn't have to be technical and brain-numbing.I have recently run into things dealing with MSFlexGrid vs DataGridView and how they link/work with database sources that confounds me. And, I am assuming there's just something I don't know about how/why VB.NET works the way it does...and I want to learn it to become a better developer.I want kind of that fun book that's easy to read, is thorough in that it teaches you a wide range of how to use/implement .NET controls/interfaces, and will fill in the gaps in my knowledge and experience.
View 1 Replies