Monday, April 11, 2011

What is the best resource for BlackBerry CLDC programming?

I deployed many midlets on Blackberry, but now I want to try their CLDC model. Never deal with it. What is the best resource to read for a quick start (except the BB examples?)

From stackoverflow

What is the best way to embed SQL in VB.NET.

I am looking for information on the best practices or project layout for software that uses SQL embedded inside VB.NET or C#. The software will connect to a full SQL DB. The software was written in VB6 and ported to VB.NET, we want to update it to use .NET functionality but I am not sure where to start with my research. We are using Visual Studio 2005. All database manipulations are done from VB.

Update: To clarify. We are currently using SqlConnection, SqlDataAdapter, SqlDataReader to connect to the database. What I mean by embed is that the SQL stored procedures are scripted inside our VB code and then run on the db. All of our tables, stored procs, views, etc are all manipulated in the VB code. The layout of our code is quite messy. I am looking for a better architecture or pattern that we can use to organize our code.

Can you recommend any books, webpages, topics that I can google, etc to help me better understand the best way for us to do this.

From stackoverflow
  • Would it be possible to convert it to using LINQ? It's safer than converting it to using regular old embedded SQL statements.

  • It sounds like you're looking for a grand theoretical book that is written for one very specific case, i.e. what is the best practice for managing our current spaghetti SQL code framework, and I don't know that I've ever seen a book or document that describes that.

    That being said, we converted several applications from VB6 to C# a few years back and were in the same place. Other than breaking apart certain modules so that their organization made more logical sense overall, our applications are essentially the same as they were, just rewritten in C#. I don't personally like the idea of separating SQL code from the function for which it was written (which is sort of what it sounds like you're trying to do); in general, if we have a function that needs to hit the database, we create a SqlCommand and, optionally, a SqlDataReader, set the CommandType to StoredProcedure and add the parameters, then perform the call and consume the result, doing with it whatever the function was programmed to do.

    I don't know that that is the best way to do it, but it works for us.

  • I am looking for a better architecture or pattern that we can use to organize our code ...

    topics that I can google

    Take a look at DAL (Data Access Layer) for database transactions Here is a link to a StackOverflow question posted by someone who is facing a similar situation

    Creating a Class Library in VB.NET

    When you google "How to create DAL", you will see list of how to create a DAL as well as what DAL is. And here is a nice article that shows how DAL fits into an N-Tier achitecture

  • In addition to what Sung Meister said, you should also consider moving the SQL from the VB.NET code into Stored Procedures, and then call the SPs from the VB.NET code (the Data Access Layer). It provides many advantages.

SharePoint 2007 Publishing site with deep menu structure

I am a beginner in SharePoint and I need to create publishing site that will have multilevel menu. Requirement is that levels will not be fixed and that client should be able to add pages and customize menu.
If I am not mistaken pages can be created only in the first level under the site. I don't see something like folders concept. For the navigation purposes I can add heading and it will be shown as another level. If I need more levels I need to create sub sites.

Site
   Page1
   Page2
   Heading
     Page3

Is this correct?

Site
   Page1
   Page2
   Sublevel_1
     Page1_1
     Sublevel_2
        Page2_1
        Sublevel_3
            Page3_1
         ...

Can I do something like this without creating SharePoint sub sites ? If I don't need I will skip writing some custom menu control or write custom SiteMapProvider. I will than need to write UI for managing navigation also.

EDIT:
I have managed to create Folder in Pages list and create (actually move) pages to that folder and even create sub folder but they are not showing on the menu not even in the navigation settings page. I can't approve folder, it is in pending status what ever I try.

I looks like this is not possible by the Andrew Connell: Subfolders are not Supported in the Pages Library in MOSS Publishing Sites

From stackoverflow
  • You can create multiple document libraries in a site and then put the pages in the various libraries. That way you wouldn't need to create sub-sites

    Robert Vuković : As I said I am beginner, can you provide me some link or some more info ? Thanks for answer, I will surely investigate this.
    marcus.greasly : You can't put publishing pages into doc libraries other than the Pages on though, so this technique has limited use..
  • Out of the box, you can modify the navigation for a Publishing site manually.

    I assume that you are after a more automated way to do this. Unfortunately, the way to modify the navigation for a PublishingWeb is through the object model and the PublishingWeb.CurrentNavigationNodes object, which would require a timer job or some other method to update as pages are edited/added/deleted.

    This is non-trivial and you will still need to create a solution/feature package. The other way is to create a custom navigation provider. The issue with both of these options (aside from the actual coding and release) is caching the navigation structure. We have used the standard web cache for the object holding the navigation structure, but using the standard user browsing (i.e. the menu code itself) to kick of a refresh of the navigation is fraught with threading issues.

What is serialization in Java?

I've made a small RSS Reader app using Swing and Eclipse keeps telling me "The serializable class MochaRSSView does not declare a static final serialVersionUID field of type long"

What is serialization and what benefits would it have?

From stackoverflow
  • Serialization is writting the object into a form which is readable and allows the object to be re-created at a different time. So if I created a widget on computer A under one JVM, serialized and saved it and sent it to computer B running a different, the other JVm would be capable of de-serializing it and re-creating it with the same values and structure

  • Serializable is a marker interfaces that tells the JVM is can write out the state of the object to some stream (basically read all the members, and write out their state to a stream, or to disk or something). The default mechanism is a binary format. You can also use it to clone things, or keep state between invocations, send objects across the network etc.

    You can let eclipse generate one for you (basically just a long random but unique ID). that means you can control when you think a class would be compatible with a serialized version, or not.

    (note that all the non transient member variables must be of a serializable class, or you will get an error - as the JVM will recurse through the structure writing out the state of each object down to the level of writing primitives to the ObjectOutputStream).

  • Serialisation is the process of converting an object to a disk-storable format, for re-load at a later time. Check the link for more info!

  • Serialization is a way to take an object (an instance of your class) and set it up for transport--across a network, to disk, etc.

  • Serialization is process of writing an representation of object's instance to a stream (or, to a sequence of bytes). See what Sun says about it: http://java.sun.com/developer/technicalArticles/Programming/serialization/

  • Java Serialisation is a way to persist object structures.

    It is best practice for serialisable class to declare serialVersionUID as a private static final long compile-time constant. This is used to check that object data and class code are claimed to be compatible.

    So why is Eclipse telling you about this? Probably, the class that you are extending (or potentially interface you are implementing) implements java.io.Serializable. That means that all subtypes, including yours are serializable. Almost certainly you don't care. You should be able to clear the warnings by applying @SuppressWarnings("serial") on the class or package (in package-info.java). If you want to forcibly prevent instances of your class being serialised, then add (from memory):

    private static final java.io.ObjectStreamField[] serialPersistentFields = {
        null
    };
    private void writeObject(
        java.io.ObjectOutputStream ou
    ) throws java.io.IOException {
        throw new java.io.NotSerializableException();
    }
    private void readObject(
        java.io.ObjectInputStream in
    ) throws java.io.IOException, java.lang.ClassNotFoundException {
        throw new java.io.NotSerializableException();
    }
    private void readObjectNoData(
    ) throws java.io.ObjectStreamException {
        throw new java.io.NotSerializableException();
    }
    

    It's probably not the best thought out system in the world (although it is much better than many people give it credit for).

  • For more information http://www.google.co.uk/search?q=what+is+java+serialization 275,000 hits.

Triple Screen Setup (3 same size vs large center)

I'm splurging for my personal system that I've wanted a while so in choices between these for programming and other uses.... (home)

  1. 28 in main center monitor (HDMI) with 2 surrounding 19in widescreen
  2. 3 seperate 19 or 21 in monitors, no large one in the center, all equal size.

What would be ideal? 28 in is huge, seems like might be a lot of neck moving and the others wouldn't be used as much....

Interested in what you'd say.

From stackoverflow
  • General Advice

    I doubt you'd be comfortable with flanking monitors on a 28" unless you're sitting far enough away -- my 27" essentially fills most of my field of view. Additionally, you probably would prefer to have all 3 be the same resolution to make it easier to go back and forth (visually and window-dragging).

    It really comes down to what you're doing, though. Some people just can't get enough pixels, whereas others are fine once they've got enough physical real estate to position their common windows all visible together.

    Problems

    I tried to use my Laptop in combination with my primary PC's 19" display (via the fantastic Synergy program), but even the difference between 1280x1024 and 1400x1050 drove me crazy (not to mention screen brightness differences).

    Software

    You'll definitely want some extra software to aid in window management across multiple monitors. Ultramon is pretty highly-recommended for things like separate screensavers and intelligent taskbars. If you're finding yourself with a large monitor and needing to quickly position windows, Winsplit (picked up from Jeff's advice, of course) is awesome.

    Darryl Hein : Visually and I would also say it's easier to drag windows across so you don't have to resize the windows to move them onto a different screen.
    Sheldon : very good point! cheaper to get the same size anyway. :-)
    Andrew Coleson : Of course I didn't take my own advice and just have one 27" monitor. But I love it for DVDs/video games and WinSplit has really helped me stay sane for window management (with multiple smaller monitors, just maximizing everything is pretty good).
  • Resolution is an important factor to consider. For example, a 28" might have a resolution of 1920x1200 while a 20" might be 1680x1050. The 28" is slightly higher, but not by much. There are two implications:

    • You normally sit farther back from a larger monitor. Even though the resolution is higher, you're sitting as close to it as the smaller monitors, so each individual pixel will be relatively bigger. (Or conversely, you're sitting farther from the small monitors than normal, so they will be harder to see).
    • When you look at something on the monitors in comparison - eg, drag a window from the big monitor to a smaller monitor, the window will appear to shrink, since the resolution is changing. Fonts will be bigger/smaller as well.

    I would personally go with identically sized monitors.

  • I have a 30in flanked by 2 24in and I absolutely love it. I have the tops of the screens lined up so speakers lay on their sides underneath.

    I started with a single 24. Then I moved to 2 24's. Now that I have 3 monitors, I'm thinking of adding another 30. Putting the 2 30's on the outside and stacking the 2 24's vertically.

    I just don't think I can have too much real estate.

    Pixels is what is important to me. Whatever screen combination gets you the most pixels, go for that. You won't regret it.

    And get a copy of UltraMon while you're at it. Multiple screens with only one taskbar is annoying and hurts my productivity.

    UPDATE:

    I've added another 30in monitor and changed the layout. Since you asked for a picture, here it is: http://www.twitpic.com/el9p6

    Chris Hynes : +1000. I've got the same setup and I love every second of working on it. Going back to anything smaller is incredibly painful.
    Sheldon : post a pic on your setup? interested in seeing it.
  • I have to vote for not only equal sized monitors, but exactly the same model too. I've worked with both 2 identical Dell 1600x1200 LCDs, and 2 same-rez but differnet physical dimension LCDs.

    When the pixel density is different on multiple displays, things are physically larger/smaller as you move them from one display to the next, and its really annoying. Think about text... 10pt font may be 2mm tall on one display and 2.5mm on another.

  • I'm currently using a 20" - 28w" x 20" LCD setup.

    You are correct - there are drawbacks to using monitors of different sizes, especially if they all have similar native resolutions.

    • Pixel sizing makes windows appear to shrink or grow since a pixel is not the same size on all of the monitors

    • Spanning a window across multiple monitors (especially if your larger monitor is centered) is nearly impossible due to the above points. If you're looking to run a wide Excel spreadsheet or something like that, forget it.

    • The point you alluded to with sitting back further and field of view isn't as big a deal, but in addition to the above points, it adds to the pile.

    If you can help it, go with three identical monitors. Size, make, model. Identical video cards helps too, as it's a pain in the neck to have windows change color when you move them across monitors.

    Sheldon : so you think your setup right now with the larger center is less than ideal, and you'd go to 3 of the 20 ins?
    AvatarKava : Yes - I'd take the tradeoff in actual real estate in exchange for image/color consistency.
    Andrew Coleson : This is definitely something to think of ahead of time -- by the time I was ready to upgrade from a single 19" to dual 19", I could no longer get the same model (or even a similar model) 19". Monitors are definitely something to plan ahead for, since they last so long. Splurge!
  • This is the type of thing that probably depends on how you plan on mounting the monitors and how good your eyesite is.

    When I was thinking about which size/quantity of displays, what I did was simply looked up the specs on line, then I cut pieces of cardboard the size of the monitor(s) I was thinking about, and then I stuck it on my desk where I was planning on putting them. I stuck a piece of paper on the front of the cardboard with what the default windows font would look like at the optimum resolution.

    Sheldon : that's actually pretty funny
  • In general, I find it helpful for all screens to have the same height and vertical resolution. I have tried to pull that off with a huge wide-screen monitor in the middle, and two 4:3 screens flanking, both rotated 90 degrees, but software issues stopped it from working.

    Sheldon : come on! You're the pro guys here... i'm sure you can get it working so when people walk in they think "WOW" you must be a hacker...(( too much Live Free or Die Hard movie recently I guess. :-)))
  • For the record, what I decided and turned out to be beautiful is triple 20 in 4:3's. Namely the HP 2065, which is a s-ips monitor. I also switched to dual 20in in potrait mode at work and find it incredible.

    If you can get the chance, use potrait mode as others have recommended. It makes MUCH more usable space and is pleasing to the eye verus the neck craning widescreens. PERFECT for programmers.

Very simple web page won't display on IE but will on everything else

Hi,

I have just started making web pages and I'm having lots of trouble with this very simple web page. I can't make anything appear on IE but it works fine on everyother browser. I'll take the liberty of putting all the code in my question because it is really short. If anyone could help me it would be great!

The html is:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html
xmlns="http://www.w3.org/1999/xhtml">
<head> <title>Rhaya<title>
        <link rel='stylesheet' media="screen" type="text/css"
href='rhaya.css'/>

</head>
<body>

<div id="masthead"> Rhaya </div>

<div id="content"> Aca va todo el
contenido </div>

<div id="footer"> ©2009 Rhaya | Teresa
Siu | Pía Fabry </div>

</body>
</html>

and the css is:

ul,ol,li {list-style:none}
body {  margin:0 auto; padding:0;font-family: Tahoma;font-size:13px; background: #fff; line-height:15px; color:#000;}
a {color: #000;text-decoration:none}
a:hover {text-decoration:none;color:#000;cursos:default;}

/* Masthead */
#masthead {
    margin:10px 0 10px 0;
    height: 50px;
    font-weight: bold;
    padding:10px;
    border:1px solid #a2ebf4;
    background-color:#e1f2f9;
    background-image: url(img/header.png);
}

/* Content */
#content {
    margin-left:0px;
    margin-bottom:10px;
    padding:10px;
    border:1px solid #000;
    min-width: 300px;
    min-height: 300px;
    font-family: Tahoma;
    font-size:13px;
}

/* Footer */
#footer {
    clear:both;
    padding:10px;
    border:1px solid #a2ebf4;
    background-color:#e1f2f9;
    text-align:center;
}

 #wrapper{
    width:1002px;
    clear:both;
    height:auto;
    margin:0px auto;
    background:#fff;
}

I'm really sorry for asking so blatantly but I really am stumped.

Thanks!

From stackoverflow
  • You have a mistake in your html head:

    <title>Rhaya<title>
    

    should be

    <title>Rhaya</title>
    
    Juan Besa : Wow... that was really simple. Thanks a lot!
  • I suggest adding the following to you css:

    div { position: relative; }
    
    MK_Dev : While this did not end up being THE solution, only person not familiar with IE6 issues could've marked this down. Well done.
  • For future reference: http://validator.w3.org/#validate_by_input Use it for resolving html issues.

    cwap : Indeed - I was just about to post this :P +1 :)
  • Wow, it actually didn't show up at all in IE.

    The reason is that you have the entire page in the title of the page. Change this:

    <title>Rhaya<title>
    

    to:

    <title>Rhaya</title>
    
  • <html
    

    tag isn't closed properly

    title tag isn't closed properly.

    Trent : the html tag spans two lines, but it looks correct
  • I have tried and tested. it is your title problem. enclosed it title /title will definitely work.

Remove non-unique ids rows

From a database backup I have records without unique Ids.

Some records have unique IDs. Some records with duplicated IDs contains different DateCreated values. Some records with duplicated IDs contains the same DateCreated values.

I'm trying to get a MSSql 2005 query will leave only unique ID values with the most recent DateCreated value.

From

ID|    DateCreated  
1 |    1/1/09
2 |    1/2/09
2 |    2/2/09
3 |    1/3/09
3 |    1/3/09

To

ID|    DateCreated  
1 |    1/1/09
2 |    2/2/09
3 |    1/3/09

Help

From stackoverflow
  • DELETE FROM myTable AS t1 
    WHERE EXISTS (
        SELECT 1 FROM myTable AS t2 
        WHERE t1.ID=t2.ID AND t1.DateCreated<t2.DateCreated)
    

    ie, delete any row where there is another row with the same id and a later creation date.

  • create table #t ( id int, date datetime )
    
    insert #t 
    values(1, getdate())
    
    insert #t 
    values(1, getdate()+1)
    
    insert #t 
    values(1, getdate()-1)
    
    insert #t 
    values(2, getdate())
    
    insert #t 
    values(2, getdate()+1)
    
    delete t 
    from #t t
    left join (select id, min(date) as date from #t group by id) as t1 
        on t.id = t1.id and t1.date = t.date
    where t1.date is null