Others The program is displayed incorrectly

MarkFact

New Member
Dec 5, 2022
5
0
I started creating applications for the phone, and I’m just starting to learn how to write code on my own, for this reason I take the code partly from the Internet. Now I have one theme of two applications and I looked at both codes and realized that they are more similar … Who knows how to avoid this? What would be the code for each unique?
Looking for a solution on the Internet, I found such a service, it seems to help, but maybe someone worked with it, what can you say?
Code:
fun main() {
    val str = "A:B:C"
    val delim = ":"
 
    val list = str.split(delim)
 
    println(list)    // [A, B, C]
}
 

Nagozo

Member
Sep 30, 2017
125
244
I genuinely can't tell what's being asked here. This post looks like it was made by an ancient chatbot AI.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,243
15,010
Now I have one theme of two applications and I looked at both codes and realized that they are more similar … Who knows how to avoid this?
Well, themes generally refer to the visual appearance, so, well use others images and even if the GUI (General User Interface) is built in the same way, they'll still looks different.

But what worry me is the "both codes", that seem to indicate that you are talking about something radically different...


What would be the code for each unique?
Without knowing the code, nor what difference you want for the theme, no one can answer this.

But you provided a code, and once again it worry me.


Code:
fun main() {
    val str = "A:B:C"
    val delim = ":"

    val list = str.split(delim)

    println(list)    // [A, B, C]
}
Let's say that it's the "both code" you talk about, and that you don't want to be similar...

What's the problem with both codes being similar exactly ?
You are asking to split a list of three letters, then to display it on the screen. There isn't hundreds way to do this, I'm not even sure that there's a dozen way to do this with a given language.

It's a rough summary, but globally speaking writing a software, it's doing what you did when you wrote the previous one, but in a different order.
You'll always have to proceed the input coming from the user, and there's not many way to do this.
You'll always have to display something on the screen, and there's not many way to do this.
You'll always have to load some data, or to save them, and here again there's not many way to do this.
You'll always have to iterate through a list, and there's what, three ways to do it, perhaps a bit more if you are inventive.
And so on, your code will always looks similar to some other code. Especially when you look at it at so low level (the core of a basic function). And it's normal.
Still globally speaking, at such low level, the more difference you see, the more you have to fear that you did it wrongly. Because your loop to count the apples, have no real reason to not looks like your loop to count the horses ; loop that itself was similar to the one you once used to count the stars.
 

Tompte

Member
Dec 22, 2017
215
155
Wow. Reading this was fascinating! I can't tell if this is real or not. Even assuming it went through an online translator the meaning is completely lost and it doesn't explain why there's is a piece of sample code there. (It looks like Kotlin.)
 

MarkFact

New Member
Dec 5, 2022
5
0
Well, themes generally refer to the visual appearance, so, well use others images and even if the GUI (General User Interface) is built in the same way, they'll still looks different.

But what worry me is the "both codes", that seem to indicate that you are talking about something radically different...




Without knowing the code, nor what difference you want for the theme, no one can answer this.

But you provided a code, and once again it worry me.




Let's say that it's the "both code" you talk about, and that you don't want to be similar...

What's the problem with both codes being similar exactly ?
You are asking to split a list of three letters, then to display it on the screen. There isn't hundreds way to do this, I'm not even sure that there's a dozen way to do this with a given language.

It's a rough summary, but globally speaking writing a software, it's doing what you did when you wrote the previous one, but in a different order.
You'll always have to proceed the input coming from the user, and there's not many way to do this.
You'll always have to display something on the screen, and there's not many way to do this.
You'll always have to load some data, or to save them, and here again there's not many way to do this.
You'll always have to iterate through a list, and there's what, three ways to do it, perhaps a bit more if you are inventive.
And so on, your code will always looks similar to some other code. Especially when you look at it at so low level (the core of a basic function). And it's normal.
Still globally speaking, at such low level, the more difference you see, the more you have to fear that you did it wrongly. Because your loop to count the apples, have no real reason to not looks like your loop to count the horses ; loop that itself was similar to the one you once used to count the stars.
The whole point of the question is whether one application code can be used for several programs. That is, do not write two different codes, but take one and edit it a little. For example, using AppRefactoring.
 

anne O'nymous

I'm not grumpy, I'm just coded that way.
Modder
Respected User
Donor
Jun 10, 2017
10,243
15,010
The whole point of the question is whether one application code can be used for several programs.
Yet what you wrote in your initial post strongly hint for the opposite:
[...] I looked at both codes and realized that they are more similar … Who knows how to avoid this? [...]
This being said, my answer already cover this.
 

Tompte

Member
Dec 22, 2017
215
155
The short answer is yes. If you construct your code in such a way that it can be reused in multiple projects, and as long as it's the same language. It's a very common thing programmers do. It's one of the skills you learn when you become a programmer. Knowing how to abstract a problem and write a general solution for it. I've worked on several games that share a common code base. You very rarely start from scratch and you try to avoid writing the same code twice.
 

MarkFact

New Member
Dec 5, 2022
5
0
The short answer is yes. If you construct your code in such a way that it can be reused in multiple projects, and as long as it's the same language. It's a very common thing programmers do. It's one of the skills you learn when you become a programmer. Knowing how to abstract a problem and write a general solution for it. I've worked on several games that share a common code base. You very rarely start from scratch and you try to avoid writing the same code twice.
Have you heard something about AppRefactoring and Code Scene services? They advised me to check the code and create a unique code