#code refactoring
Explore tagged Tumblr posts
stevegy-sh-cn · 11 months ago
Text
The evolution of a rocket engine
Tumblr media
comparing it with the code refactoring...
2 notes · View notes
intelliatech · 1 year ago
Text
Top 10 ChatGPT Prompts For Software Developers
Tumblr media
ChatGPT can do a lot more than just code creation and this blog post is going to be all about that. We have curated a list of ChatGPT prompts that will help software developers with their everyday tasks. ChatGPT can respond to questions and can compose codes making it a very helpful tool for software engineers.
While this AI tool can help developers with the entire SDLC (Software Development Lifecycle), it is important to understand how to use the prompts effectively for different needs.
Prompt engineering gives users accurate results. Since ChatGPT accepts prompts, we receive more precise answers. But a lot depends on how these prompts are formulated. 
To Get The Best Out Of ChatGPT, Your Prompts Should Be:
Clear and well-defined. The more detailed your prompts, the better suggestions you will receive from ChatGPT.
Specify the functionality and programming language. Not specifying what you exactly need might not give you the desired results.
Phrase your prompts in a natural language, as if asking someone for help. This will make ChatGPT understand your problem better and give more relevant outputs.
Avoid unnecessary information and ambiguity. Keep it not only to the point but also inclusive of all important details.
Top ChatGPT Prompts For Software Developers
Let’s quickly have a look at some of the best ChatGPT prompts to assist you with various stages of your Software development lifecycle.
1. For Practicing SQL Commands;
Tumblr media
2. For Becoming A Programming Language Interpreter;
Tumblr media
3. For Creating Regular Expressions Since They Help In Managing, Locating, And Matching Text.
Tumblr media
4. For Generating Architectural Diagrams For Your Software Requirements.
Prompt Examples: I want you to act as a Graphviz DOT generator, an expert to create meaningful diagrams. The diagram should have at least n nodes (I specify n in my input by writing [n], 10 being the default value) and to be an accurate and complex representation of the given input. Each node is indexed by a number to reduce the size of the output, should not include any styling, and with layout=neato, overlap=false, node [shape=rectangle] as parameters. The code should be valid, bugless and returned on a single line, without any explanation. Provide a clear and organized diagram, the relationships between the nodes have to make sense for an expert of that input. My first diagram is: “The water cycle [8]”.  
Tumblr media
5. For Solving Git Problems And Getting Guidance On Overcoming Them.
Prompt Examples: “Explain how to resolve this Git merge conflict: [conflict details].” 6. For Code generation- ChatGPT can help generate a code based on descriptions given by you. It can write pieces of codes based on the requirements given in the input. Prompt Examples: -Write a program/function to {explain functionality} in {programming language} -Create a code snippet for checking if a file exists in Python. -Create a function that merges two lists into a dictionary in JavaScript.  
7. For Code Review And Debugging: ChatGPT Can Review Your Code Snippet And Also Share Bugs.
Prompt Examples: -Here’s a C# code snippet. The function is supposed to return the maximum value from the given list, but it’s not returning the expected output. Can you identify the problem? [Enter your code here] -Can you help me debug this error message from my C# program: [error message] -Help me debug this Python script that processes a list of objects and suggests possible fixes. [Enter your code here]
8. For Knowing The Coding Best Practices And Principles: It Is Very Important To Be Updated With Industry’s Best Practices In Coding. This Helps To Maintain The Codebase When The Organization Grows.
Prompt Examples: -What are some common mistakes to avoid when writing code? -What are the best practices for security testing? -Show me best practices for writing {concept or function} in {programming language}.  
9. For Code Optimization: ChatGPT Can Help Optimize The Code And Enhance Its Readability And Performance To Make It Look More Efficient.
Prompt Examples: -Optimize the following {programming language} code which {explain the functioning}: {code snippet} -Suggest improvements to optimize this C# function: [code snippet] -What are some strategies for reducing memory usage and optimizing data structures? 
10. For Creating Boilerplate Code: ChatGPT Can Help In Boilerplate Code Generation.
Prompt Examples: -Create a basic Java Spring Boot application boilerplate code. -Create a basic Python class boilerplate code
11. For Bug Fixes: Using ChatGPT Helps Fixing The Bugs Thus Saving A Large Chunk Of Time In Software Development And Also Increasing Productivity.
Prompt Examples: -How do I fix the following {programming language} code which {explain the functioning}? {code snippet} -Can you generate a bug report? -Find bugs in the following JavaScript code: (enter code)  
12. Code Refactoring- ChatGPt Can Refactor The Code And Reduce Errors To Enhance Code Efficiency, Thus Making It Easier To Modify In The Future.
Prompt Examples –What are some techniques for refactoring code to improve code reuse and promote the use of design patterns? -I have duplicate code in my project. How can I refactor it to eliminate redundancy?  
13. For Choosing Deployment Strategies- ChatGPT Can Suggest Deployment Strategies Best Suited For A Particular Project And To Ensure That It Runs Smoothly.
Prompt Examples -What are the best deployment strategies for this software project? {explain the project} -What are the best practices for version control and release management?  
14. For Creating Unit Tests- ChatGPT Can Write Test Cases For You
Prompt Examples: -How does test-driven development help improve code quality? -What are some best practices for implementing test-driven development in a project? These were some prompt examples for you that we sourced on the basis of different requirements a developer can have. So whether you have to generate a code or understand a concept, ChatGPT can really make a developer’s life by doing a lot of tasks. However, it certainly comes with its own set of challenges and cannot always be completely correct. So it is advisable to cross-check the responses. Hope this helps. Visit us- Intelliatech
0 notes
gleecus-techlabs-blogs · 2 years ago
Text
Techniques to Perform Code Refactoring
Red green refactoring
Refactoring by abstraction
Composing method
Simplifying methods
Moving features between objects
Preparatory refactoring
0 notes
orthogonal-slut · 4 months ago
Text
refactoring your own code is so embarrassing. who would ever write this trash pile of - oh...
31 notes · View notes
frog707 · 21 days ago
Text
Slimming down
Like all software metrics, "lines of code" shouldn't be applied blindly.
Today my software WIP's LoC metric is rapidly declining because I've created C++ macros to generate boilerplate code. I'm talking code I used to copy and paste every time I needed it.
This is the kind of refactoring I love, because it means less code to maintain in the future. Fewer chances for coding errors. Less scrolling through source code to find the interesting parts.
And in this case, I believe it also uncovered (and solved) a bug. So a big win all around.
But from a strict "lines of code" perspective, this would be considered a step backward.
4 notes · View notes
akyrahaiato · 1 month ago
Text
If I could go back in time,
I would have used a state machine.
4 notes · View notes
compnion · 2 months ago
Text
i dont want this bootcamp to turn me into a misandrist but being the smartest girl is truly worth dirt because almost EVERY man there thinks he’s fucking better than me i am SO exhausted
3 notes · View notes
turnedpalefromlackofsun · 4 months ago
Text
i found a guide on how to find a girlfriend as a lesbian in tech and it says to join as many open source projects as possible
do people actually talk when doing open source work? dont people just argue in the pull requests? ive never seen a single sentence without an insult or a slur in it in the discussions
or just a passive aggressive "RESOLVED" every time someone comments anything and without a link to the fix
"consider platforms such as github and stackoverflow" HELP ME
im losing it
is this serious? unironically? NO!!!!
4 notes · View notes
kaiserouo · 1 year ago
Text
Tumblr media Tumblr media
Sick of setting up the scene, adjust all settings, and render 8 images individually by hand for every character i want reference for
Spend >2 hours coding the functionality to do the whole procedure in like 5 clicks
Spend more time just to code something that saves time? Sure why not.
14 notes · View notes
la-principessa-nuova · 7 months ago
Text
ewww… i just got a notification that the new product owner on my old team updated a user story i wrote like 3-4 years ago and used AI to generate acceptance criteria
and it’s soooo bad. like it’s not even acceptance criteria, it’s just my explanation of the issue formatted with given/when/then
but like the given is supposed to be the state prior to testing the criterion, but this is the explanation for why the work needs to be done
and the when is supposed to be the action to test the criterion but it’s just “when we decide which approach to implement” in more words basically
and the then is supposed to be the outcome to be tested for acceptance and it’s just a list of options.
i really hope she was just playing around with the AI and then going to work on it with the team bc this is… not it…
2 notes · View notes
dontcode · 2 years ago
Text
Tumblr media
I think my commit name is very funny
8 notes · View notes
cauldronofmorning · 2 years ago
Text
Aya just feels like home you know? Like I feel safe and happy with her, and I want to know all the paintings in it and understand what they mean.
2 notes · View notes
otter-byte · 2 years ago
Text
Tumblr media
copilot calling my code a hack. Okay bestie how about I wave a magnet over your severs and we'll see how you feel.
5 notes · View notes
Text
0 notes
frog707 · 2 years ago
Text
refactoring
I lied when I said I was going to work next on loading a 3-D model. Sorry, old habit! Actually, I went straight into refactoring. Let me explain...
The English Wikipedia defines refactoring as "the process of restructuring existing computer code . . . without changing its external behavior", which is fairly accurate, though lacking in motivation.
My back-of-mind definition would be "changes to code whose primary purpose is not to add features or solve issues, but to make the codebase easier to maintain".
Back when I worked for corporations, I got in the habit of never mentioning refactoring around anyone who wasn't a software developer. If my boss (or my boss's boss) knew I was making changes (and spending work hours) on something other than approved features or known issues, awkward questions would arise. (Like, do we have a billing code for that?)
Anyone who's worked intimately with a large software project knows that if changes are made only for features and issues, the project will accumulate "technical debt" that makes it difficult to maintain: hard to explain/learn/understand/remember how it works and hard to make changes without introducing bugs.
Both of today's refactorings focussed on the BaseApplication class, which became unwieldy weeks ago. Last night the source file for the class reached 1901 lines of Java code (not counting blanks, comments, and javadoc). I don't place a hard limit on lines of code in a class, but a file containing 1901 LoCs positively screams technical debt. It's especially painful these days, since I'm working on a laptop with a tiny screen and using a track pad instead of a mouse. (I spend lots of time scrolling back and forth, hunting for the lines I need to change.) Cramming as much as possible into a single file makes some sense for a tutorial, but I see the V-Sport project as something I'll be maintaining for many years.
First I split off all the code that deals with physical devices and put that in a new PhysicalDevice class. The change greatly clarified which properties of the physical device matter and how that information is accessed.
Then I split off all the code that deals with texture data into a new Texture class. The new class bundles up 3 related Vulkan resources and provides a clear lifecycle of create/use/destroy. I expect it to minimize duplication of code when the project transitions (sometime in the near future) from a single texture to multiple textures.
I'm subjectively pleased with how smoothly today's refactoring went. One measure of its success is that BaseApplication shrank from 1901 to 1650 lines of code. Still plenty of room for improvement, though!
26 notes · View notes
dkettchen · 1 month ago
Text
I'm refactoring some code I wrote last year during bootcamp and I just narrowed down long ass code from like 3 data cleaning stages (=a lot of clunky code!) to a few tiny helper functions to apply to a dataframe (=very little, neat code!) in one afternoon 😩
1 note · View note