Click here to Skip to main content
15,993,665 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Dynamic SQL Pin
jochance2-Jul-24 7:14
jochance2-Jul-24 7:14 
GeneralRe: Dynamic SQL Pin
Sander Rossel9-Jul-24 1:05
professionalSander Rossel9-Jul-24 1:05 
GeneralHow, VS Code? This is amazing. Pin
honey the codewitch22-Jun-24 14:51
mvahoney the codewitch22-Jun-24 14:51 
GeneralRe: How, VS Code? This is amazing. Pin
Richard Andrew x6423-Jun-24 4:32
professionalRichard Andrew x6423-Jun-24 4:32 
GeneralRe: How, VS Code? This is amazing. Pin
honey the codewitch23-Jun-24 4:35
mvahoney the codewitch23-Jun-24 4:35 
GeneralRe: How, VS Code? This is amazing. Pin
Richard Andrew x6423-Jun-24 4:45
professionalRichard Andrew x6423-Jun-24 4:45 
GeneralRe: How, VS Code? This is amazing. Pin
honey the codewitch23-Jun-24 4:46
mvahoney the codewitch23-Jun-24 4:46 
GeneralRe: How, VS Code? This is amazing. Pin
Dave Kreskowiak23-Jun-24 6:11
mveDave Kreskowiak23-Jun-24 6:11 
I started playing with Copilot a couple days ago. I found the experience a bit freaky at first, kind of like the thing being inside your head, anticipating what you want to do. It was really good at first, but as the application I was working on evolved, getting into the more detailed items, it started writing code with mistakes in it.

I wanted to see what it could do, and started with letting it write the code as much as possible (you know, like the typical QA question at CodeProject. Smile | :) ). I started with a simple FileSystemWatcher app and described that I wanted a WPF app that monitored a directory and its subdirectories and logged all the changes it saw. It generated a simple app with a FileSystemWatcher, but more like a Console app with no XAML UI. It wrote everything with no problems, working as expected. Impressive, but I wanted to see how far it could go.

Next, I told it to change the app to a XAML UI, using MVVM and a TreeView, and keep that updated with changes as they happened in the file system. It explained everything, walking me through all the code changes and what I needed to add/remove. It came up with the hierarchy model and the correct XAML bindings and everything! That was mind-blowing! I didn't expect it to figure out how to rewrite the code for an entirely new UI. Talk about freaky!

I was just evolving the app, one step at a time, describing what I wanted the app to do, and it was coming up with the right suggestions, and that's when the mistakes started. The first mistake was a minor issue with a XAML binding that it didn't wire up correctly, one-way instead of two-way. I pointed that out and it actually said I was correct and came up with the correct, simple fix. Wait, this thing can figure out its own mistakes?!

OK. Let's give it something more difficult to understand. At this point, the window was split into the TreeView on the left and a log of FileSystemWatcher events on the right. I got it to coloring the event messages, based on event types, like Changed, Created, Deleted. It put together a ListBox with a TextBlock for each item in the list, with the correct DataTriggers for each message type and the correct Foreground and Background property setters. I told it to change the ListBox to a ListView, and it correctly rewrote the XAML and kept all the formatting. I told it "that didn't look right to me and to back out that change," and it did exactly that, going back to the ListBox code. Mind blown!

Very impressive so far. Let's dig into a little more detail. The background of the TextBlock items in the ListBox only went so far as the length of the text, but I want it to fill the width of the available space in the ListBox. I described this, and it actually understood that, coming up with wrapping each TextBlock in a Border object and moving the DataTriggers for the Foreground and Background property setters to the Border tag for formatting! Whaaaaa?! Cool.

But here's the bigger mistake. The Border tag in XAML doesn't support a Foreground property, only a Background. It didn't immediately understand the context the Border was being used for and went for just moving the TextBlock.Style section to the Border.Style section without checking the property setters in their new context like we would.

That was interesting and gave a bit of insight into the limits of the context it's keeping track of. It won't generate its own "sub context(?)," like checking its work as it makes changes, in this case, checking the property setters for correctness in their new home. It can recover, however, if you know about and point out the mistake. I told it the Border element doesn't support a Foreground property and asked it "what it could do about that," in those exact terms. To my amazement, it told me I was right about Foreground property, and it fixed the problem by moving the Foreground Setters back to DataTriggers the TextBlock.Style section!

WTF | :WTF: I was floored.

My second experience with Copilot was a bit harsher. Keeping with the "typical CodeProject question poster" theme, I intentionally simplified my questions, leaving out all context as to what I wanted to do and in all my questions. Copilot did not like that AT ALL. It was constantly telling me to provide more context in my questions and commands, but it was coming up with possible intents asking me questions about what I was talking about and rephrasing my questions into terms and contexts it could understand, just like we do while answering questions here. It gives you links you can click on for your questions but rephrased in the context it thinks you're talking about, and it'll answer them and make suggestions.

I found that very interesting. It seems to get just as frustrated as we do with people here. It makes me wonder if it was trained not only on GitHub code, but on all of SO and CP.

Is it going to replace developers? No, not a chance. You still have to learn how to break your problems and questions down into smaller, organized chunks. You have to think about your problems and not only how to break them down into smaller chunks but do so in a manner you can accurately describe while providing proper context.

Like in my sig, asking questions is a skill, even when asking them of an AI, and this is something the noobs and non-coders struggle to learn.

GeneralRe: How, VS Code? This is amazing. Pin
Luschan25-Aug-24 19:32
Luschan25-Aug-24 19:32 
GeneralWhat the hell gcc? Pin
honey the codewitch17-Jun-24 21:20
mvahoney the codewitch17-Jun-24 21:20 
GeneralRe: What the hell gcc? Pin
RainHat17-Jun-24 22:57
RainHat17-Jun-24 22:57 
GeneralRe: What the hell gcc? Pin
honey the codewitch17-Jun-24 22:58
mvahoney the codewitch17-Jun-24 22:58 
GeneralRe: What the hell gcc? Pin
RainHat18-Jun-24 0:51
RainHat18-Jun-24 0:51 
GeneralRe: What the hell gcc? Pin
0x01AA18-Jun-24 1:23
mve0x01AA18-Jun-24 1:23 
GeneralRe: What the hell gcc? Pin
honey the codewitch18-Jun-24 4:12
mvahoney the codewitch18-Jun-24 4:12 
GeneralRe: What the hell gcc? Pin
jochance18-Jun-24 2:59
jochance18-Jun-24 2:59 
GeneralRe: What the hell gcc? Pin
k505418-Jun-24 3:17
mvek505418-Jun-24 3:17 
GeneralRe: What the hell gcc? Pin
Rick York18-Jun-24 4:53
mveRick York18-Jun-24 4:53 
GeneralRe: What the hell gcc? Pin
honey the codewitch18-Jun-24 5:03
mvahoney the codewitch18-Jun-24 5:03 
GeneralRe: What the hell gcc? Pin
k505418-Jun-24 5:20
mvek505418-Jun-24 5:20 
GeneralRe: What the hell gcc? Pin
honey the codewitch18-Jun-24 5:38
mvahoney the codewitch18-Jun-24 5:38 
GeneralRe: What the hell gcc? Pin
k505418-Jun-24 5:47
mvek505418-Jun-24 5:47 
GeneralRe: What the hell gcc? Pin
honey the codewitch18-Jun-24 5:55
mvahoney the codewitch18-Jun-24 5:55 
GeneralRe: What the hell gcc? Pin
k505418-Jun-24 6:43
mvek505418-Jun-24 6:43 
GeneralRe: What the hell gcc? Pin
honey the codewitch18-Jun-24 6:48
mvahoney the codewitch18-Jun-24 6:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.