Results 1 to 17 of 17

Thread: .NET Framework Discussion

Hybrid View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Apr 2002
    Location
    California
    Posts
    160

    .NET Framework Discussion

    I am creating this thread to touch on a few points about the features of the .NET Framework.

    I am currently on track to Microsoft MCSD certification, but besides getting certified my major goal is understanding some of the most important features of the .NET framework. So here are some things I would like to discuss.

    - If datasets are disconnected then does'nt that make it possible for another user to be modifying data that you are manipulating yourself? If so, does that create a situation where the data can be inconsistent? Maybe I really dont understand datasets that well but it seems to me that would be the case.

    - I beleive that typed datasets are best suited for small and enterprise solutions. I have seen many different views on this. What are some of your ideas on this topic?

    - In ASP.NET is cached information stored for a user's session or is that available to all users? If it is cached per user then why not just use session varaibles to cache information?

    - I have been studying the MCAD/MCSD microsoft press self-paced training kit and nowhere in there do they explain best practices for developing applications. As far as I have seen from practice exam tests some of the questions are geared toward the best way to implement something. I have not seen any other study guides so i dont know if there are guides that explain best practices. Is there anyone else on the same path that have encountered this or is it just me? It seems that the guides just explain the basics of using the .NET framework which is consistent with the practice exams except for the questions that ask a specific way to do something where the answers are all correct and are not asking select all that apply.

    - The other thing about the consistency between study guides and the actual exam is the fact that the guide shows one way of implementing something and the test ask the question relating to that particular idea that shows a different way. For instance,

    The book shows:

    VB Code:
    1. dim conDB as new sqlconnection("server=myserver;Database=mydatabase;Integrated Security=SSPI")
    The question may include example code like:
    VB Code:
    1. dim conDB as new sqlconnection
    2.  
    3. conDB.ConnectionString = "Datasource=myserver;Initial Catalog=mydatabase;Trusted_Connection=true"
    While this is just an example, is there a best way between these two. This goes for many other programming practices as well.

    In my opinion the best way would be the first, then if you need to connect to another source u can change the connection string later. This goes for other objects as well.

    Please feel free to add to this discussion. This is a completely open discussion.

    Thanks.
    Jason Moore

    Software Engineer, Database Architect, Web Designer

    (C#,VB/NET,ASP/NET,COLDFUSION,JAVASCRIPT,SQL)

    http://www.gatorstudios.com
    [email protected]

  2. #2
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474

    Re: .NET Framework Discussion

    Originally posted by jwmoore2001
    - If datasets are disconnected then does'nt that make it possible for another user to be modifying data that you are manipulating yourself? If so, does that create a situation where the data can be inconsistent? Maybe I really dont understand datasets that well but it seems to me that would be the case.

    That's what referred to as Data Concurrency and you can read more about it here:
    http://msdn.microsoft.com/library/de...cyChecking.asp
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  3. #3
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    - In ASP.NET is cached information stored for a user's session or is that available to all users? If it is cached per user then why not just use session varaibles to cache information?
    The cache is available accross session boundries. Remember, even though the Cache, Application, and Session seem to be doing the same thing, the Cache is very different from the Application and Session variables in what it can do. The Cache can expire, call a function when it expires, expire when a file changes, etc...

  4. #4
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464

    Re: .NET Framework Discussion

    Originally posted by jwmoore2001
    - The other thing about the consistency between study guides and the actual exam is the fact that the guide shows one way of implementing something and the test ask the question relating to that particular idea that shows a different way. For instance,

    The book shows:

    VB Code:
    1. dim conDB as new sqlconnection("server=myserver;Database=mydatabase;Integrated Security=SSPI")
    The question may include example code like:
    VB Code:
    1. dim conDB as new sqlconnection
    2.  
    3. conDB.ConnectionString = "Datasource=myserver;Initial Catalog=mydatabase;Trusted_Connection=true"
    While this is just an example, is there a best way between these two. This goes for many other programming practices as well.

    In my opinion the best way would be the first, then if you need to connect to another source u can change the connection string later. This goes for other objects as well.
    As a developer, you need to understand the reason that both are correct. This comes down to understanding objects and how they are written. Passing in a connection string to the constructor only sets a internal variable equal to it. The EXACT same thing happens when you use the .ConnectionString property. There really is no difference except two lines of code compared to one.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Apr 2002
    Location
    California
    Posts
    160
    That's what referred to as Data Concurrency and you can read more about it here:
    I understand Data Concurrency. It just seems to me that working directly against a database using transactions and MTC is a much better solution than having to deal with the issues that datasets pose.

    - With Transactions against databases you can lock the entire row or table until the transaction is completed or failed.

    - With datasets you are working with essentially a local copy of the data and that does not lock anything, except when accessing the database for updates or refreshing. So when USER1 adds/modifies 100 rows to TABLEA disconnected and goes to update the database. Now USER2 has deleted a row or modified a row that USER1 modified or deleted from their disconnected dataset. How is that handled, and if its as complicated as it looks to resolve those issues I would find it much easier and more stable to just use transactions against a database directly.
    Jason Moore

    Software Engineer, Database Architect, Web Designer

    (C#,VB/NET,ASP/NET,COLDFUSION,JAVASCRIPT,SQL)

    http://www.gatorstudios.com
    [email protected]

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Apr 2002
    Location
    California
    Posts
    160

    .NET Framework discussion

    The cache is available accross session boundries. Remember, even though the Cache, Application, and Session seem to be doing the same thing, the Cache is very different from the Application and Session variables in what it can do. The Cache can expire, call a function when it expires, expire when a file changes, etc...
    - "Cache is available across session boundaries" does that mean available to all users connected to the application?

    - Sessions expire and sessions have the ability to call functions when they expire as well.

    As a developer, you need to understand the reason that both are correct. This comes down to understanding objects and how they are written. Passing in a connection string to the constructor only sets a internal variable equal to it. The EXACT same thing happens when you use the .ConnectionString property. There really is no difference except two lines of code compared to one.
    Absolutely correct... You can either instantiate the object and passing the connection string along with the call or set the string later. But when an exam asks you which lines you would use and both are correct and the question is not a "select all that apply". What would be the one you would choose? Keep in mind that particular question has never come up for that line of code that was just an example, but it has come up for similar instances.
    Jason Moore

    Software Engineer, Database Architect, Web Designer

    (C#,VB/NET,ASP/NET,COLDFUSION,JAVASCRIPT,SQL)

    http://www.gatorstudios.com
    [email protected]

  7. #7
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Originally posted by jwmoore2001
    I understand Data Concurrency. It just seems to me that working directly against a database using transactions and MTC is a much better solution than having to deal with the issues that datasets pose.

    - With Transactions against databases you can lock the entire row or table until the transaction is completed or failed.

    - With datasets you are working with essentially a local copy of the data and that does not lock anything, except when accessing the database for updates or refreshing. So when USER1 adds/modifies 100 rows to TABLEA disconnected and goes to update the database. Now USER2 has deleted a row or modified a row that USER1 modified or deleted from their disconnected dataset. How is that handled, and if its as complicated as it looks to resolve those issues I would find it much easier and more stable to just use transactions against a database directly.
    I think the disconnected mode is quite convenient. However as that article mentioned it may depend on your scenario to use what method and how to deal with concurrency.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Apr 2002
    Location
    California
    Posts
    160

    Datasets

    Trust me, I am not knocking the .NET framework at all. I am just trying to gather other people's input on the issues of the new technology.

    Another thing that I found was the white paper on the differences in C# and VB .NET. I dont remember where I found it but i am sure it was on the Microsoft Site somewhere. It states that there are no differences except programmatic and logic. But when you talk about things that might seem small like the fact that Visual C# wont recognize COM properties and VB does is interesting. It may seem small to some and huge to others.

    What is the purpose of C#? To allow c++ programmers to be more comfortable in developing ASP.NET web applications. Now we have 2 different languages for the same development environment such as ASP.NET. Now you have to distinguish between C# and VB.NET ASP applications. So if a company has been using the same framework but a different language you wont be able to procur that job because the language written is just syntatically different, rather than being able to live with denying potential customers that use PHP or JSP and so on and so forth (Those jobs are for the gutter compared to .NET)
    Jason Moore

    Software Engineer, Database Architect, Web Designer

    (C#,VB/NET,ASP/NET,COLDFUSION,JAVASCRIPT,SQL)

    http://www.gatorstudios.com
    [email protected]

  9. #9
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    Now you have to distinguish between C# and VB.NET ASP applications
    Why? I don't understand this. Specially when it comes to ASP . NET applications the difference between them is only syntax IMHO.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Apr 2002
    Location
    California
    Posts
    160

    .NET Framework discussion

    Why? I don't understand this. Specially when it comes to ASP . NET applications the difference between them is only syntax IMHO.
    What I mean is that I know the .NET Framework pretty well, and lets say I came into a job that had some stuff written in C#. Even though the difference is syntax, there is still a difference and I would still need a good refference to navigate the code. We now have C++, VB, VB.NET, and C# to worry about.

    Just a thought about the purpose of C# and its role in Windows-Base and Web-Based development.
    Jason Moore

    Software Engineer, Database Architect, Web Designer

    (C#,VB/NET,ASP/NET,COLDFUSION,JAVASCRIPT,SQL)

    http://www.gatorstudios.com
    [email protected]

  11. #11
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    I don't think we might worry about that too much. I never did anything in C# but I can easily understand it and convert to VB .NET if I need. And I guess the purpose of introducing C# is not only because of C++ users but also because of Java programmers as the syntax is fairly simillar.
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

  12. #12

    Thread Starter
    Addicted Member
    Join Date
    Apr 2002
    Location
    California
    Posts
    160

    .NET Framework discussion

    good point about the Java programmers. I would have to say thats a pretty well suited argument for developing a language that developers from other technologies can be familiar with. It just gets a little confusing when having to work with several languages at once, I am sure you understand that.
    Jason Moore

    Software Engineer, Database Architect, Web Designer

    (C#,VB/NET,ASP/NET,COLDFUSION,JAVASCRIPT,SQL)

    http://www.gatorstudios.com
    [email protected]

  13. #13
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    Sessions expire and sessions have the ability to call functions when they expire as well
    No, there is a BIG difference between the Cache expiration and the Session expiring.

    The session expires either when a timeout happens, or (flakely) when someone leaves the site. This calls a global.asax method.

    A Cache object will expire when I tell it to. If I put something in the Cache, and set its expiration to 10 minutes, it will be gone in 10 minutes. A session can stay around indefinately as long as the user is doing something and the server doesn't restart the process.

    This expiration policy allows me to access the database every 10 minutes and store information in the Cache that all pages have access to. This makes one database call every ten minutes, as opposed to 1 call for every page request. This dramatically helps performance on high availability apps.

    Absolutely correct... You can either instantiate the object and passing the connection string along with the call or set the string later. But when an exam asks you which lines you would use and both are correct and the question is not a "select all that apply". What would be the one you would choose? Keep in mind that particular question has never come up for that line of code that was just an example, but it has come up for similar instances.
    Maybe it was the example you used, but you will NEVER see a question like that on a MS test. I just took one last monday, and no, not even close to something like that.

    There are other examples you probably should have used instead, like which way would be better to do something in such and such situation. In that case, you need to know the differences between how to do things. Again, if you are truly studying for a test and want to learn the reasons behind the answers, this should be so obvious when you come accross a question like that. In the example you used, there is functionally NO difference, therefor you will not see that on the test.



    Here is a good one though (and fits your question better):

    You want to speed up performance to make the app as fast as you can, which would increase speed the most:

    1.
    Code:
    Dim ds As New DataSet
    'Fill dataset here
    Dim dv As New DataView(ds.Tables(0), "CompanyID=20", "CompanyDescription", DataViewRowState.CurrentRows)
    or
    2.
    Code:
    Dim ds As New DataSet
    'Fill dataset here
    Dim dv As New DataView(ds.Tables(0))
    dv.RowFilter = "CompanyID=20"
    dv.Sort = "CompanyDescription"
    dv.RowStateFilter = DataViewRowState.CurrentRows
    The answer is 1, it will provide better performance. The reason is because it filters and sorts only once. Number 2 is slightly slower because you are doing one thing at a time.

  14. #14
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    As far as C# and VB.Net....

    If you are going to be working with .Net for a job, you would only benefit yourself to know both. I switch back and forth between the two with very little problems. The only problem I have is sometimes I start typing things like Dim or the ; at the end of the lines...etc... That stuff though is easy to stop, I usually only do it once or twice a day.

  15. #15

    Thread Starter
    Addicted Member
    Join Date
    Apr 2002
    Location
    California
    Posts
    160

    .NET Framework discussion

    A Cache object will expire when I tell it to. If I put something in the Cache, and set its expiration to 10 minutes, it will be gone in 10 minutes. A session can stay around indefinately as long as the user is doing something and the server doesn't restart the process.
    You can also expire sessions when you tell them to, and you can expire individual objects by setting them to nothing. But you do have a good point in that Cache objects will stay even when you leave the site, and that the cache object can be reset at a specified time and continue holding until the time limit is up again at which point you can re-cache the object.

    Maybe it was the example you used, but you will NEVER see a question like that on a MS test. I just took one last monday, and no, not even close to something like that.
    I do remember a practice exam question that asked the following.

    You are setting up a connection to a database, what is the best method to implement that? (Worded as best I can)

    1. I would set the connection in a global variable.

    2. I would set the connection for every page that requires data access.

    3. I would create a server componenet to connect to the database and place it on the pages that require access to the database.

    I dont remember the other answers but from that right there, I would have to say that if your data application requires access to the database on every page then a global variable might work best. They do not say whether or not the application does require access on every page.

    The answer is 1, it will provide better performance. The reason is because it filters and sorts only once. Number 2 is slightly slower because you are doing one thing at a time.
    I am not sure but dont both those lines of code work the same, if you instantiate an object by passing the default paramaters, the internal class will set each property and call the sort and filter procedures individually the same way it would if you where calling each individual procedure yourself.
    Jason Moore

    Software Engineer, Database Architect, Web Designer

    (C#,VB/NET,ASP/NET,COLDFUSION,JAVASCRIPT,SQL)

    http://www.gatorstudios.com
    [email protected]

  16. #16
    PowerPoster hellswraith's Avatar
    Join Date
    Jul 2002
    Location
    Washington St.
    Posts
    2,464
    I am not sure but dont both those lines of code work the same, if you instantiate an object by passing the default paramaters, the internal class will set each property and call the sort and filter procedures individually the same way it would if you where calling each individual procedure yourself.
    That is how it would seem, but if you set the filter seperate than the sort, then it has to go through the datatable twice, whereas if you pass them into the constructor at the same time, it can compare both values at the same time as it goes through the dataset, and therefor only has to do it once.

    Here is what MSDN says about it:
    DataView Construction
    The DataView builds an index for the data in the underlying DataTable when both the DataView is created, and when the Sort, RowFilter or RowStateFilter properties are modified. When creating a DataView object, use the DataView constructor that takes the Sort, RowFilter, and RowStateFilter values as constructor arguments (along with the underlying DataTable). The result is the index is built once. Creating an "empty" DataView and setting the Sort, RowFilter or RowStateFilter properties afterward results in the index being built at least twice.
    You can read it here:
    http://msdn.microsoft.com/library/de...adonetbest.asp

  17. #17

    Thread Starter
    Addicted Member
    Join Date
    Apr 2002
    Location
    California
    Posts
    160

    .NET Framework discussion

    Good answer.

    Aside from some of the issues of the .NET Framework. I have found that working with Visual Studio .NET and the Framework has been a great experience in capabilities, functionality, error correction and debugging. There has not been a time that I could not resolve a bug, or create work around when running into problems(which is not as heavy as Win32 API). In the the Win32 API, I could spend hours trying to debug and correct errors. Great improvement.

    I have a question for you, when creating objects in .NET is there a way allow only one class to call Friend or Public properties or procedures. For instance:

    VB Code:
    1. Friend Class Shape
    2.  
    3. Private intSize as integer
    4.  
    5. Friend Property Size() as integer
    6. Get
    7.  Size = intSize
    8. End Get
    9. Set (ByVal Value as integer)
    10.  intSize = Value
    11. End Set
    12. End Property
    13.  
    14. End Class
    15.  
    16. Friend Class Circle
    17.  
    18. Dim objShape as Shape
    19.  
    20. objShape.Size = 10
    21.  
    22. End Class

    Lets just say that I only want the Class Circle to be able to set that property. The reason being, if I dont want the webform class to be able to set that property. Or is the proper way just to inherit.

    VB Code:
    1. Friend MustInherit Class Shape
    2.  
    3. Friend MustInherit Property Size() as integer
    4. ' other code here
    5. '
    6.  
    7. End Class
    Jason Moore

    Software Engineer, Database Architect, Web Designer

    (C#,VB/NET,ASP/NET,COLDFUSION,JAVASCRIPT,SQL)

    http://www.gatorstudios.com
    [email protected]

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width